“`”
回答:
<strong>exe</strong>:
application.Exename
ExpandFileName
<strong>Dll</strong>:
1)方法一:
<pre><code>Function GetDllPath(sDllName:string):string;
var
ModuleFileName:array[0..255] of char;
begin
//{取得dll的实际位置}
GetModuleFileName(GetModuleHandle(sDllName), @ModuleFileName[0], SizeOf(ModuleFileName));
Result := ModuleFileName;
end;
</code></pre>
2)方法二:
<pre><code>Function GetDllPath:string;
var
ModuleName:string;
begin
SetLength(ModuleName, 255);
//取得Dll自身路径
GetModuleFileName(HInstance, PChar(ModuleName), Length(ModuleName));
Result := PChar(ModuleName);
end;
</code></pre>
<pre><code> "“`
Was this helpful?
0 /
0