‎2011 Apr 05 2:12 PM
Hi
How can i use a function from a standard DLL that in c:\winnt\system32.?.
Ami
‎2011 Apr 05 2:21 PM
The name of the DLL is ADVAPI32.DLL and the function i want to use is LogonUser, i want to use it in an ABAP program
thanx Ami
‎2011 Sep 05 4:48 PM
Hello ami,
here is the solution to your question - I know, a little bit late, but I hope not to late.
Cheers
Stefan
"-Begin-----------------------------------------------------------------
Report ZLOGON.
"-Variables-----------------------------------------------------------
Data Win32 Type OLE2_OBJECT.
Data Token Type String Value '0000'.
Data hToken Type Integer.
Data phToken Type Integer.
Data ret Type Integer.
"-Main----------------------------------------------------------------
Create Object Win32 'DynamicWrapperX'.
If Win32-Handle > 0.
"-Define external functions---------------------------------------
Call Method Of Win32 'Register' Exporting
#1 = 'advapi32.dll' #2 = 'LogonUserA'
#3 = 'i=sssuup' #4 = 'r=l'.
Call Method Of Win32 'Register' Exporting
#1 = 'kernel32.dll' #2 = 'CloseHandle'
#3 = 'i=h' #4 = 'r=l'.
Call Method Of Win32 'Register' Exporting
#1 = 'kernel32.dll' #2 = 'GetLastError'
#3 = 'r=u'.
Call Method Of Win32 'StrPtr' = phToken Exporting
#1 = Token #2 = 's'.
Call Method Of Win32 'LogonUserA' = ret Exporting
#1 = 'bambi' #2 = '.' #3 = 'hugo' #4 = 2 #5 = 0 #6 = phToken.
If ret <> 0.
"-Logon successful----------------------------------------------
Write: 'Logon as bambi user'.
Call Method Of Win32 'NumGet' = hToken Exporting
#1 = phToken.
Call Method Of Win32 'CloseHandle' = ret Exporting
#1 = hToken.
If ret = 0.
Call Method Of Win32 'GetLastError' = ret.
Write: / ret.
EndIf.
Else.
Call Method Of Win32 'GetLastError' = ret.
Write: / ret.
EndIf.
Free Object Win32.
EndIf.
"-End-------------------------------------------------------------------
Edited by: Stefan Schnell on Sep 6, 2011 7:07 AM
‎2011 Apr 05 2:27 PM
Hi...
Use this example
INCLUDE OLE2INCL.
"-Constants----
DATA IDYes TYPE i VALUE 6.
DATA IDNo TYPE i VALUE 7.
"-Variables----
DATA Win32 TYPE OLE2_OBJECT.
DATA ret TYPE i.
CREATE OBJECT Win32 'DynamicWrapperX'.
CALL METHOD OF Win32 'Register' (REGISTER IS A DLL)
EXPORTING
#1 = 'user32.dll' #2 = 'MessageBoxW'
#3 = 'i=hwwu' #4 = 'r=l'.
CALL METHOD OF Win32 'MessageBoxW' = ret (MESSAGEBOXW IS YOUR FUNCTION )
EXPORTING
#1 = 0 #2 = 'Hello World'
#3 = 'Test' #4 = 4.
IF ret = IDYes.
WRITE 'Ja'.
ELSEIF ret = IDNo.
WRITE 'Nein'.
ELSE.
WRITE '?'.
ENDIF.
FREE OBJECT Win32.
That should solve your question...
Hope to help, bye...
‎2011 Apr 05 2:29 PM
Sorry I mean
#1 parameter is you DLL
CALL METHOD OF Win32 'Register'
EXPORTING
#1 = 'user32.dll' #2 = 'MessageBoxW'
#3 = 'i=hwwu' #4 = 'r=l'.
‎2011 Apr 05 2:40 PM
Hi
you need also to register on your client this dll to make the example code working
http://www.script-coding.com/dynwrapx_eng.html#download
Put the dynwrapx.dll into win..system32 folder
and register after with command from RUN windows menù -> regsvr32.exe dynwrapx.dll
‎2011 Apr 05 3:06 PM
‎2011 Apr 05 3:08 PM
Hi..
have you done a debug session? What goes wrong?...
I tried and it worked with me....
‎2011 Apr 05 3:12 PM
hi
thanks but i dont have a way to upload the reg. file to all the users computers,
second i didnt know where to put the name of the dll and the function name ,
‎2011 Apr 05 3:45 PM
Hi...
try to
CALL METHOD OF Win32 'Register'
EXPORTING
#1 = 'advapi32.dll' #2 = 'LogonUser'
#3 = 'i=hwwu' #4 = 'r=l'.
CALL METHOD OF Win32 'LogonUser' = ret
EXPORTING
*#1 = 0 #2 = 'Hello World'
*#3 = 'Test' #4 = 4.
Here you'll have to use parameters of your function as indicated on msdn documentation
__in LPTSTR lpszUsername,
__in_opt LPTSTR lpszDomain,
__in LPTSTR lpszPassword,
__in DWORD dwLogonType,
__in DWORD dwLogonProvider,
__out PHANDLE phToken
More info I founded on http://msdn.microsoft.com/en-us/library/aa378184(v=vs.85).aspx
Naturally you must adeguate the code ... That's how it works.
‎2011 Apr 05 4:10 PM
‎2011 Apr 05 4:33 PM
HI...
no your Dll should be a standard dll....always present...
‎2011 Jul 06 11:46 PM
Hello Roberto.
I'm trying to call the example function 'MessageBoxW' from USER32.dll but when executes the function:
CALL METHOD OF win32 'MessageBoxW' = ret
EXPORTING
#1 = 0
#2 = 'Hello World'
#3 = 'Test'
#4 = 4.
The "RET" variable, always was 2.
And the program not make anything.
Please your help.
Regards.