November 26th, 2004, 08:26 AM
Conditional API Declaration
I have an application that is getting run on a few thousand machines (.
The problem i have is they are 9x/NT/2000 and XP.
When I encounter an XP box i am calling the CreateProcessWithLogonW API function that is found in advapi32g.dll, which works great, however the app will not run on NT or 9x, coz NT does not contain the function in the dll and 9x does not even have the dll.
I dont want to reference the function on NT or 9x, but i have to declare the function in the APP as XP uses it? is there a way to only declare this API function on 2000+ machines or get NT/9x to ignore the error of it not being found?
(I have to have 1 exe)..
Thanks for any help...
November 26th, 2004, 12:31 PM
I suppose you can find the version of windows and if the version is WinXP or higher you can call the dll, otherwise ignore it.
There are a few ways to find the Windows version.
Here is a borland's article on that issue: http://community.borland.com/article/0,1410,15974,00.html
November 26th, 2004, 01:20 PM
I guess you are declaring the function like this?
function CreateProcessWithLogonW(.... params ...) stdcall external 'advapi32g.dll';
You should use a different way to load the dll:
CreateProcessWithLogonW:function (.... params ...) ; stdcall;
if DllHandle>0 then begin
if @CreateProcessWithLogonW<>nil then begin
// Everything ok. You can use the function now.
end else begin
// DLL found but function not.
end else begin
// DLL not found
Last edited by M.Hirsch; November 26th, 2004 at 01:21 PM.
Reason: corrected the order of parameters