首页 > 代码库 > Can a windows dll retrieve its own filename?
Can a windows dll retrieve its own filename?
http://stackoverflow.com/questions/2043/can-a-windows-dll-retrieve-its-own-filename
A windows exe file has access to the command string which invoked it, including its path and filename. eg.
C:\MyApp\MyApp.exe --help.
But this is not so for a dll invoked via LoadLibrary
. Does anyone know of a way for a dll to find out what its path and filename is?
Specifically I‘m interested in a Delphi solution, but I suspect that the answer would be pretty much the same for any language.
I think you‘re looking for GetModuleFileName.
{ If you are working on a DLL and are interested in the filename of the DLL rather than the filename of the application, then you can use this function:}function GetModuleName: string;var szFileName: array[0..MAX_PATH] of Char;begin FillChar(szFileName, SizeOf(szFileName), #0); GetModuleFileName(hInstance, szFileName, MAX_PATH); Result := szFileName;end;
Can a windows dll retrieve its own filename?
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。