当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.GetType方法代码示例

本文整理汇总了C#中System.IntPtr.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.GetType方法的具体用法?C# IntPtr.GetType怎么用?C# IntPtr.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestUseCase

        public static void TestUseCase(Assert assert)
        {
            assert.Expect(7);

            var t1 = new Type();
            assert.Ok(t1 != null, "#565 t1");

            var t2 = new ValueType();
            assert.Ok(t2 != null, "#565 t2");

            var t3 = new IntPtr();
            assert.Ok(t3.GetType() == typeof(IntPtr) , "#565 t3");

            var t4 = new UIntPtr();
            assert.Ok(t4.GetType() == typeof(UIntPtr), "#565 t4");

            var t5 = new ParamArrayAttribute();
            assert.Ok(t5 != null, "#565 t5");

            var t6 = new RuntimeTypeHandle();
            assert.Ok(t6.GetType() == typeof(RuntimeTypeHandle), "#565 t6");

            var t7 = new RuntimeFieldHandle();
            assert.Ok(t7.GetType() == typeof(RuntimeFieldHandle), "#565 t7");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:25,代码来源:N565.cs

示例2: TaskbarHelper

        public TaskbarHelper()
        {
            ProgramForm = Program.Form;
            WindowHandle = ProgramForm.Handle;
            try
            {
                MicrosoftWindowsAPICodePackShell = Assembly.LoadFrom("Microsoft.WindowsAPICodePack.Shell.dll");

                Type TaskbarManager = MicrosoftWindowsAPICodePackShell.GetType("Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager");
                windowsTaskbar = TaskbarManager.GetProperty("Instance").GetValue(TaskbarManager, null);

                //windowsTaskbar.ApplicationId = "Transmission Remote Dotnet";
                TaskbarManager.GetProperty("ApplicationId").SetValue(windowsTaskbar, "Transmission Remote Dotnet", null);

                //windowsTaskbar.SetApplicationIdForSpecificWindow(WindowHandle, windowsTaskbar.ApplicationId);
                MethodInfo SetApplicationIdForSpecificWindow = TaskbarManager.GetMethod("SetApplicationIdForSpecificWindow", new Type[] { WindowHandle.GetType(), typeof(string) });
                SetApplicationIdForSpecificWindow.Invoke(windowsTaskbar, new object[] {
                    WindowHandle,
                    TaskbarManager.GetProperty("ApplicationId").GetValue(windowsTaskbar, null)
                });

                iconPause = Icon.FromHandle(Properties.Resources.pause16.GetHicon());
                iconPauseAll = Icon.FromHandle(Properties.Resources.player_pause_all.GetHicon());
                iconStartAll = Icon.FromHandle(Properties.Resources.player_play_all.GetHicon());
                iconAddTorrent = Icon.FromHandle(Properties.Resources.add16.GetHicon());

                //buttonStartAll = new ThumbnailToolbarButton(iconStartAll, OtherStrings.StartAll);
                //buttonPauseAll = new ThumbnailToolbarButton(iconPauseAll, OtherStrings.PauseAll);
                //buttonAddTorrent = new ThumbnailToolbarButton(iconAddTorrent, OtherStrings.NewTorrentIs);

                Type ThumbnailToolbarButton = MicrosoftWindowsAPICodePackShell.GetType("Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolBarButton");
                buttonStartAll = Activator.CreateInstance(ThumbnailToolbarButton, new object[] { iconStartAll, OtherStrings.StartAll });
                buttonPauseAll = Activator.CreateInstance(ThumbnailToolbarButton, new object[] { iconPauseAll, OtherStrings.PauseAll });
                buttonAddTorrent = Activator.CreateInstance(ThumbnailToolbarButton, new object[] { iconAddTorrent, ProgramForm.AddTorrentString });

                SetConnected(false);

                //buttonStartAll.Click+=new EventHandler<ThumbnailButtonClickedEventArgs>(buttonStartAll_Click);
                //buttonPauseAll.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPauseAll_Click);
                //buttonAddTorrent.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonAddTorrent_Click);

                Type ThumbnailButtonClickedEventArgs = MicrosoftWindowsAPICodePackShell.GetType("Microsoft.WindowsAPICodePack.Taskbar.ThumbnailButtonClickedEventArgs");
                EventInfo ei = ThumbnailToolbarButton.GetEvent("Click");
                ei.AddEventHandler(buttonStartAll, Delegate.CreateDelegate(ei.EventHandlerType, null, GetType().GetMethod("buttonStartAll_Click")));
                ei.AddEventHandler(buttonPauseAll, Delegate.CreateDelegate(ei.EventHandlerType, null, GetType().GetMethod("buttonPauseAll_Click")));
                ei.AddEventHandler(buttonAddTorrent, Delegate.CreateDelegate(ei.EventHandlerType, null, GetType().GetMethod("buttonAddTorrent_Click")));

                //windowsTaskbar.ThumbnailToolbars.AddButtons(WindowHandle, buttonStartAll, buttonPauseAll, buttonAddTorrent);
                object ThumbnailToolbars = TaskbarManager.GetProperty("ThumbnailToolBars").GetValue(windowsTaskbar, null);
                Type ThumbnailToolBarManager = MicrosoftWindowsAPICodePackShell.GetType("Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolBarManager");
                Type ThumbnailToolbarButtonArray = MicrosoftWindowsAPICodePackShell.GetType("Microsoft.WindowsAPICodePack.Taskbar.ThumbnailToolBarButton[]");
                MethodInfo AddButtons = ThumbnailToolBarManager.GetMethod("AddButtons", new Type[] { WindowHandle.GetType(), ThumbnailToolbarButtonArray });
                Array ThumbnailToolbarButtons = Array.CreateInstance(ThumbnailToolbarButton, 3);
                ThumbnailToolbarButtons.SetValue(buttonStartAll, 0);
                ThumbnailToolbarButtons.SetValue(buttonPauseAll, 1);
                ThumbnailToolbarButtons.SetValue(buttonAddTorrent, 2);
                AddButtons.Invoke(ThumbnailToolbars, new object[] { WindowHandle, ThumbnailToolbarButtons });
            }
            catch (TargetInvocationException)
            { // this is normal: this is only supported on Windows 7 or newer.
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString());
            }
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:66,代码来源:TaskbarHelper.cs

示例3: typeof

        //pguidCmdGroup must be declared as IntPtr not a GUID, as pguidCmdGroup may be null, hence generating execption
        int IOleCommandTarget.Exec(IntPtr pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int hr = Hresults.S_OK;
            
            if ((pguidCmdGroup != m_NullPointer) &&
                (Type.GetTypeCode(pguidCmdGroup.GetType()) != TypeCode.Empty))
            {
                try
                {
                    ////Allocate mem for a GUID
                    //byte[] bguid = Guid.Empty.ToByteArray();
                    ////Copy incoming into byte array
                    //Marshal.Copy(pguidCmdGroup, bguid, 0, bguid.Length);
                    ////back to GUID
                    //Guid guid = new Guid(bguid);

                    Guid guid = (Guid)Marshal.PtrToStructure(pguidCmdGroup, typeof(Guid));

                    //Only group we are interested
                    if (guid == Iid_Clsids.CLSID_CGID_DocHostCommandHandler)
                    {
                        //http://support.microsoft.com/kb/261003
                        if (nCmdID == (int)OLECMDID.OLECMDID_SHOWSCRIPTERROR)
                        {
                            //Default Continue running scripts
                            if (pvaOut != IntPtr.Zero)
                                Marshal.GetNativeVariantForObject(true, pvaOut);
                            //false -> stop running scripts
                            if (ScriptError != null)
                            {
                                ScriptErrorEvent.SetParameters();
                                try
                                {
                                    IHTMLDocument2 doc2 = (IHTMLDocument2)Marshal.GetObjectForNativeVariant(pvaIn);
                                    IHTMLWindow2 win2 = (IHTMLWindow2)doc2.parentWindow;
                                    IHTMLEventObj2 eveobj = (IHTMLEventObj2)win2.eventobj;

                                    if (eveobj != null)
                                    {
                                        ScriptErrorEvent.lineNumber = (int)eveobj.getAttribute("errorLine", 0);
                                        ScriptErrorEvent.characterNumber = (int)eveobj.getAttribute("errorCharacter", 0);
                                        ScriptErrorEvent.errorCode = (int)eveobj.getAttribute("errorCode", 0);
                                        ScriptErrorEvent.errorMessage = eveobj.getAttribute("errorMessage", 0) as string;
                                        ScriptErrorEvent.url = eveobj.getAttribute("errorUrl", 0) as string;
                                    }
                                }
                                catch (Exception)
                                {
                                }
                                ScriptError(this, ScriptErrorEvent);
                                if (pvaOut != IntPtr.Zero)
                                    Marshal.GetNativeVariantForObject(ScriptErrorEvent.continueScripts, pvaOut);
                                ScriptErrorEvent.SetParameters();
                           }
                        }
                        else
                            hr = Hresults.OLECMDERR_E_NOTSUPPORTED;
                    }
                    else
                        hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
                }
                catch (Exception)
                {
                    hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
                }
            }
            else
                hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
            return hr;
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:71,代码来源:cEXWB.cs

示例4: Respawn

        public void Respawn(IntPtr body)
        {
            //IPhysicsObject prueba = (IPhysicsObject)body;
            string dato = body.GetType().ToString();

            Notifier.AddMessage("Respawned");
            Matrix mat = Matrix.CreateTranslation(StartPos) *
                Matrix.CreateRotationX(MathHelper.ToRadians(90));
            Newton.NewtonBodySetMatrixRecursive(body, MatrixHelper.ToFloats(mat));
        }
开发者ID:virucho,项目名称:UDDMG,代码行数:10,代码来源:RaceCar.cs

示例5: WBStop

        //pguidCmdGroup must be declared as IntPtr not a GUID, as pguidCmdGroup may be null, hence generating execption
        int IOleCommandTarget.Exec(IntPtr pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int hr = Hresults.S_OK;

            //Catch stop
            if( (nCmdID == (int)OLECMDID.OLECMDID_STOP) && (WBStop != null) )
            {
                WBStop(this);
            }

            if ((pguidCmdGroup != m_NullPointer) &&
                (Type.GetTypeCode(pguidCmdGroup.GetType()) != TypeCode.Empty))
            {
                try
                {
                    ////Allocate mem for a GUID
                    //byte[] bguid = Guid.Empty.ToByteArray();
                    ////Copy incoming into byte array
                    //Marshal.Copy(pguidCmdGroup, bguid, 0, bguid.Length);
                    ////back to GUID
                    //Guid guid = new Guid(bguid);

                    Guid guid = (Guid)Marshal.PtrToStructure(pguidCmdGroup, typeof(Guid));
                    //if( (this.m_DocDone) && (guid == Iid_Clsids.CGID_Explorer) && (nCmdID == 67) )
                    //{
                    //    //for 67 script exec, 69 timer/something is going
                    //    //66 open
                    //    //CGID_Explorer = 000214d0-0000-0000-c000-000000000046
                    //    //for 11 guid = 000214d4-0000-0000-c000-000000000046 , undocumented???
                    //    Debug.Print("IOleCommandTarget.Exec=> " + this.m_WBWebBrowser2.LocationURL);
                    //}

                    //Only group we are interested
                    //F38BC242-B950-11D1-8918-00C04FC2C836
                    if ( guid == Iid_Clsids.CLSID_CGID_DocHostCommandHandler)
                    {
                        //http://support.microsoft.com/kb/261003
                        if( nCmdID == (int)OLECMDID.OLECMDID_SHOWSCRIPTERROR)
                        {
                            //false -> stop running scripts
                            if ((pvaIn != IntPtr.Zero) && (ScriptError != null))
                            {
                                //default: continueScripts = true
                                ScriptErrorEvent.SetParameters();
                                try
                                {
                                    IHTMLDocument2 doc2 = (IHTMLDocument2)Marshal.GetObjectForNativeVariant(pvaIn);
                                    IHTMLWindow2 win2 = (IHTMLWindow2)doc2.parentWindow;
                                    IHTMLEventObj2 eveobj = (IHTMLEventObj2)win2.eventobj;

                                    if (eveobj != null)
                                    {
                                        ScriptErrorEvent.lineNumber = (int)eveobj.getAttribute("errorLine", 0);
                                        ScriptErrorEvent.characterNumber = (int)eveobj.getAttribute("errorCharacter", 0);
                                        ScriptErrorEvent.errorCode = (int)eveobj.getAttribute("errorCode", 0);
                                        ScriptErrorEvent.errorMessage = eveobj.getAttribute("errorMessage", 0) as string;
                                        ScriptErrorEvent.url = eveobj.getAttribute("errorUrl", 0) as string;
                                    }
                                }
                                catch (Exception)
                                {
                                }
                                ScriptError(this, ScriptErrorEvent);
                                if (pvaOut != IntPtr.Zero)
                                    Marshal.GetNativeVariantForObject(ScriptErrorEvent.continueScripts, pvaOut);
                                ScriptErrorEvent.SetParameters();
                            }
                            else
                            {
                                //Default Continue running scripts
                                if (pvaOut != IntPtr.Zero) //VARIANT (VT_NULL) - object (null)
                                    Marshal.GetNativeVariantForObject(true, pvaOut);
                            }
                        }
                        else
                            hr = Hresults.OLECMDERR_E_NOTSUPPORTED;
                    }
                    else
                        hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
                }
                catch (Exception)
                {
                    hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
                }
            }
            else
                hr = Hresults.OLECMDERR_E_UNKNOWNGROUP;
            return hr;
        }
开发者ID:aldoblack,项目名称:webknowledge,代码行数:90,代码来源:cEXWB.cs

示例6: SetTypedReference

	public static void SetTypedReference(TypedReference target, Object value)
			{
				if(value == null)
				{
					throw new ArgumentNullException("value");
				}
			#if !ECMA_COMPAT
				value = Convert.ChangeType(value, GetTargetType(target));
			#endif
				if(!ClrSetTypedReference(target, value))
				{
					throw new InvalidCastException
						(String.Format
							(_("InvalidCast_FromTo"),
 						     value.GetType().FullName,
							 GetTargetType(target).FullName));
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:TypedReference.cs


注:本文中的System.IntPtr.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。