- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
How can I use the DLLMain WinAPI in a Fortran DLL? Do I reference it from another function which is exported to the main program?
I want to check if the parent process has detached from the DLL successfully.
Thank you for any suggestions.
Daniel.
How can I use the DLLMain WinAPI in a Fortran DLL? Do I reference it from another function which is exported to the main program?
I want to check if the parent process has detached from the DLL successfully.
Thank you for any suggestions.
Daniel.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You write your own function called DllMain. This is called by Windows when the DLL is attached or detached. Such a function would start out as follows:
[fortran]function DllMain (hInstDLL, fdwReason, lpReserved) !DEC$ ATTRIBUTES STDCALL, DECORATE, DLLEXPORT, ALIAS:"DllMain" :: DllMain USE IFWINTY IMPLICIT NONE integer(BOOL) :: DllMain integer(HANDLE), intent(IN) :: hinstDLL integer(DWORD), intent(IN) :: fdwReason integer(LPVOID), intent(IN) :: lpReserved[/fortran]It would return a result of TRUE if successful or FALSE if unsuccessful. (Note that these are not the Fortran LOGICAL values .TRUE. and .FALSE.)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You write your own function called DllMain. This is called by Windows when the DLL is attached or detached. Such a function would start out as follows:
[fortran]function DllMain (hInstDLL, fdwReason, lpReserved) !DEC$ ATTRIBUTES STDCALL, DECORATE, DLLEXPORT, ALIAS:"DllMain" :: DllMain USE IFWINTY IMPLICIT NONE integer(BOOL) :: DllMain integer(HANDLE), intent(IN) :: hinstDLL integer(DWORD), intent(IN) :: fdwReason integer(LPVOID), intent(IN) :: lpReserved[/fortran]It would return a result of TRUE if successful or FALSE if unsuccessful. (Note that these are not the Fortran LOGICAL values .TRUE. and .FALSE.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thank you! You're a star.
Sure, TRUE and FALSE are the ones declared in IFWINTY.
Thanks again. I can finally make sure the DLL frees the memory.
Daniel.
Thank you! You're a star.
Sure, TRUE and FALSE are the ones declared in IFWINTY.
Thanks again. I can finally make sure the DLL frees the memory.
Daniel.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page