LookupPrivilegeValue - how to declare?

Serj HAMMER

Junior Racer
Help me please: how to declare <I>LookupPrivilegeValue</I> - external API function in Progress 4GL?
Example:

PROCEDURE LookupPrivilegeValue EXTERNAL "advapi32.dll":
DEFINE INPUT PARAMETER lpSystemName AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER lpName AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER lpLuid AS MEMPTR NO-UNDO.
END PROCEDURE.

This not work. I can't found something on www.global-shared.com in everything.zip file.
I found on peg this URL. http://www.peg.com/lists/api/history/200210/msg00037.html
Good example. But this don't work too.
 

bendaluz2

Member
What do you mean it doesnt work. What errors do you get?

From just looking at what you've posted i'd say you are missing your "A" from the end of the procedure name.

i.e.

<pre>
PROCEDURE LookupPrivilegeValue{&A} EXTERNAL "advapi32.dll":
DEFINE INPUT PARAMETER lpSystemName AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER lpName AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER lpLuid AS MEMPTR NO-UNDO.
END PROCEDURE.
</pre>
 

SPlayer

New Member
First Message post my frend.

So, this my code.

&GLOBAL-DEFINE BOOL AS LONG
&GLOBAL-DEFINE BYTE AS BYTE
&GLOBAL-DEFINE ATOM AS SHORT
&GLOBAL-DEFINE UINT AS UNSIGNED-SHORT
&GLOBAL-DEFINE HWND AS LONG
&GLOBAL-DEFINE HANDLE AS LONG
&GLOBAL-DEFINE PHANDLE AS LONG
&GLOBAL-DEFINE DWORD AS LONG
&GLOBAL-DEFINE LPDWORD AS LONG
&GLOBAL-DEFINE PLUID AS MEMPTR

PROCEDURE LookupPrivilegeValueA EXTERNAL "advapi32.dll":
DEFINE INPUT PARAMETER lpSystemName {&LPCTSTR} NO-UNDO.
DEFINE INPUT PARAMETER lpName {&LPCTSTR} NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER lpLuid {&PLUID} NO-UNDO.
DEFINE RETURN PARAMETER Result {&BOOL} NO-UNDO.
END PROCEDURE. /* END OF PROCEDURE LookupPrivilegeValue */

DEFINE VAR lLUID AS HANDLE NO-UNDO.
DEFINE VAR Result AS INTEGER NO-UNDO.

RUN LookupPrivilegeValueA ("","SeIncreaseQuotaPrivilege",INPUT-OUTPUT lLUID,OUTPUT Result).

After run this, i have folow error message.

Mismatch in the parameter datatypes in DLL procedure LookupPrivilegeValueA advapi32.p. (3231)

I download hpApi library from On www.global-shared.com.
Unfortunately in this library i can't found LookupPrivilegeValue declare.

I try LookupPrivilegeValue and LookupPrivilegeValueA with same results.
 

bendaluz2

Member
From what you posted, LPCTSTR doesnt seem to be defined, and also you havent defined the size of lpLuid, like in the example you quoted.

Hope this helps :)
 

SPlayer

New Member
Sorry. Of course I missed one string.

&GLOBAL-DEFINE LPCTSTR AS CHAR

But I don't undersand what you mean about size of LUID.
 

bendaluz2

Member
Your
<code>
DEFINE INPUT-OUTPUT PARAMETER lpLuid {&PLUID} NO-UNDO.
</code>
defines a pointer to memory. You have to define how large that block is before you can use it.

The command
<code>
set-size( tmpluid ) = 4 + 4.
</code>
in the peg example sets the size of the area tmpluid points to, to be 8 bytes. Not sure the full definition for the structure, but from the example
<code>
get-long( tmpLuid, 1 ).
</code>
we can see that the first four bytes of the pointer are used for a long value. Check out msdn, you can probably find out what the other parts of the definition are without too much trouble (assuming you need to use them)

also remember to deallocate the memory area once your have finished with it, or your program will eat memory. do
<code>
set-size( tmpluid ) = 0.
</code>
at the end of scope of the memptr.
 
Top