Can a windows dll retrieve its own filename?
2020-12-13 13:52
标签:style blog http io color ar for sp div 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. But this is not so for a dll invoked via 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. Can a windows dll retrieve its own filename? 标签:style blog http io color ar for sp div 原文地址:http://www.cnblogs.com/shangdawei/p/4056725.htmlC:\MyApp\MyApp.exe --help.
LoadLibrary
. Does anyone know of a way for a dll to find out what its path and filename is?{
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;
上一篇:C++传值和传引用
下一篇:Python3正则表达式
文章标题:Can a windows dll retrieve its own filename?
文章链接:http://soscw.com/essay/33432.html