Link to home
Start Free TrialLog in
Avatar of spaznuski
spaznuski

asked on

running an executable that links Netapi32.dll; but ignores the funtion on win98

OK I asked this question already but my intentions were not clear hence the help i got was not what I wanted. Here is my question, I have two stdcalls to netapi32.dll and because of those two calls the app wont load on a 9x machine (I Know the reasons why) what I want to know is if there is a way for me to ignore the calls to the dll on a 9x machine or am I just out of luck. The Functions in question are

function NetShareEnum(servername: PWideChar; level: DWORD; bufptr: PBYTE;
  prefmaxlen: DWORD;  entriesread: PDWORD;  totalentries: PDWORD;
  resume_handle: PDWORD): DWORD;   stdcall;  external 'netapi32.dll' Name 'NetShareEnum';

function NetApiBufferFree(Buffer: Pointer): DWORD;
stdcall; external 'netapi32.dll' Name 'NetApiBufferFree';

SO Once again I want a way to ignore the above if the exe is running on a 9x machine
Please Help
Thanx
Avatar of DaFox
DaFox

Hi.

Use dynamic linking instead of doing it statically. Then you're able to check the OS before you try to import the functions.

Example:

var
  function NetShareEnum(servername: PWideChar; level: DWORD; bufptr: PBYTE; prefmaxlen: DWORD;  entriesread: PDWORD;  totalentries: PDWORD; resume_handle: PDWORD): DWORD; stdcall;

...


function IsNTPlatform: Boolean;
var
  osv : TOSVERSIONINFO;
begin
  Result := false;
  osv.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFO);
  GetVersionEx(osv);
  if (osv.dwPlatformId = VER_PLATFORM_WIN32_NT) then result:= true;
end;

...

if isNTPlatform then
begin
  Lib := LoadLibrary('netapi32.dll');
  @hNetShareEnum := GetProcAddress(Lib, 'NetShareEnum');
end;


Markus
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
spaznuski:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.