This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Get hWnd for Current Application Snippet (ArcObjects .NET 10.4 SDK) |
Get the Windows Handle (hWnd) of the application that is currently running.
///<summary>Get the Windows Handle (hWnd) of the application that is currently running.</summary> /// ///<returns>A System.Int32 that is windows handle of the running application.</returns> /// ///<remarks>Note: If the code is running inside an ArcGIS desktop application, you should use the IApplicaiton.hWnd to get the Windows Handle.</remarks> public System.Int32 GetHWndForCurrentApplication() { return System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(); }
'''<summary>Get the Windows Handle (hWnd) of the application that is currently running.</summary> ''' '''<returns>A System.Int32 that is windows handle of the running application.</returns> ''' '''<remarks>Note: If the code is running inside an ArcGIS desktop application, you should use the IApplicaiton.hWnd to get the Windows Handle.</remarks> Public Function GetHWndForCurrentApplication() As System.Int32 Return System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()(0)).ToInt32() End Function