How to call WinAPI function SetDllDirectory() in Delphi?

无人久伴 提交于 2019-12-04 07:59:00

This should do the trick:

function SetDllDirectory(lpPathName:PWideChar): Bool; stdcall; external 'kernel32.dll' name 'SetDllDirectoryW';

Calling SetDllDirectory('') doesn't work? I see that it is declared properly in the latest versions of Windows.pas. If you have a version of Delphi in which it isn't declared, you can upgrade to the latest version of Delphi, or declare it yourself.

Update: And there you go... Jens just posted the declaration.

uses DSiWin32;

if not DSiSetDllDirectory('path') then
   ....

DSiSetDllDirectory will also take care of dynamic linking and will fail gracefully on pre-XP SP1 systems.

DSiWin32 is released as a freeware.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!