Skip to content

Commit

Permalink
Added FancyGetModuleHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
dalefugier committed Nov 21, 2024
1 parent f6a650a commit 1924813
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cpp/SampleCommands/SampleFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,20 @@ bool IsRhinoReparented()
return hParent != hDesktop;
}

/// <summary>
/// Returns module handle where "this" function is running in: EXE or DLL.
/// </summary>
HMODULE FancyGetModuleHandle()
{
HMODULE hModule = NULL;
::GetModuleHandleEx(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR)FancyGetModuleHandle,
&hModule
);
return hModule;
}


/// <summary>
/// Begin a CRhinoDoc undo record.
Expand Down
5 changes: 5 additions & 0 deletions cpp/SampleCommands/SampleFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ bool RhinoHasFocus();
/// </summary>
bool IsRhinoReparented();

/// <summary>
/// Returns module handle where "this" function is running in: EXE or DLL.
/// </summary>
HMODULE FancyGetModuleHandle();


/// <summary>
/// CRhinoDoc::BeginUndoRecord and CRhinoDoc::EndUndoRecord helper.
Expand Down

0 comments on commit 1924813

Please sign in to comment.