C language function:GetModuleFileName sample codes

Search sample code in the internet.It is the result.

TITLE : AutoCAD DevBlog: RealDWG
if (GetModuleFileName(NULL, buf, MAX_PATH) != 0).......

TITLE : LoadDLLViaAppInit | Didier Stevens
I realize this approach allows a lot of flexibility, but you could also just change the code for your injected DLL: in DllMain(), check if the fdwReason parameter is DLL_PROCESS_ATTACH, and then check the process name via GetModuleFileName(NULL, szProcess, sizeof(szProcess)). Then decide to load or not. If not, return FALSE from DllMain()........
search Google