Externs other than "win32"

BlitzMax Forums/BlitzMax Programming/Externs other than "win32"

Grey Alien(Posted 2007) [#1]
Hi, how can I find other Windows API functions that don't appear to be in Win32? For example, I want to extern this:

GetSecurityInfo

Which MSDN says this about:


Client
Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server
Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Header
Declared in Aclapi.h.

Library
Use Advapi32.lib.

DLL
Requires Advapi32.dll.



So how can I extern that please? I tried using Extern "Advapi32.lib" and "Advapi32" and "Aclapi.h" and "Aclapi" but Max just says "Unrecognized calling convention 'advapi32.lib'".

So I went to my MinGW folder and did a find in files search for GetSecurityInfo and found it was in aclapi.h and libadvapi32.a. So I tried externing these with and without the extension, but to no avail. Help!

Also what would happen on a 98/ME machine as it seems that function doesn't exist? Is it safe to have the Extern providing that I don't actually call the function (by detecting what OS I'm running first), or will the actual Extern fail.

Thanks in advance for any help.


Azathoth(Posted 2007) [#2]
You use Import "-l" to link libraries, eg. Import "-ladvapi32". Extern "Win32" makes the functions usable by the Blitzmax code, from what I can tell the "Win32" means the stdcall calling convention.


Grey Alien(Posted 2007) [#3]
OK thanks. However, I did this:

Import "-ladvapi32"

Then later on I called GetSecurityInfo in my code and the IDE says "Identifier 'GetSecurityInfo' not found" when I compile so I guess it didn't work :-(

Simple example:

Import "-ladvapi32"

Print GetSecurityInfo(Null,Null,Null,Null,Null,Null,Null,Null)


I'm really a complete noob at this so if anyone can help I'd really appreciate it.


Azathoth(Posted 2007) [#4]
You've still got to use Extern "Win32" to make the function visible to BlitzMax.


Kev(Posted 2007) [#5]
code removed, beat by Azathoth :P

this might be of use to you also, gives a list of api calls and there '.dll' location.

http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html


Grey Alien(Posted 2007) [#6]
Azahoth. I see, OK I'll try.

Meanwhile I tried this:

Local advapi32 = LoadLibraryW ( "advapi32.dll" )
Local GetSecurityInfo(Handle:Int,ObjectType:Int,SecurityInfo:Int,..
	ppsidOwner:Byte Ptr,ppsidGroup:Byte Ptr,ppDacl:Byte Ptr,ppSacl:Byte Ptr,..
	ppSecurityDescriptor:Byte Ptr) = GetProcAddress ( advapi32, "GetSecurityInfo" )
Print GetSecurityInfo(Null,Null,Null,Null,Null,Null,Null,Null)

And it return a value so something is working...

Kev: Thanks, looks useful.


Kev(Posted 2007) [#7]
the value returned is 6, the error code for 'The handle is invalid.'

i have a little gui util that will tell you any error codes returned when making an api call.

clicky
http://www.winblitz3d.co.uk/ErrorShow.zip

kev


Grey Alien(Posted 2007) [#8]
Hey neat little app, cool! Yeah I know that 6 means that, it's because I'm passing in a null handle, I have some other code that gets a valid one.