JSchmitt Posted February 2, 2007 Share Posted February 2, 2007 Hello together,my appended Function returns the correct DomainJoinStatus, but the name is just a number ... why?Does someone has an idea why?Thanks in advanceJochen;####################################################################################################; Sources for NetGetJoinInformation; http://msdn2.microsoft.com/en-us/library/aa370423.aspx; http://vbnet.mvps.org/index.html?code/netw...information.htm;####################################################################################################$ComputerJoinedDomain = ""$ComputerDomainJoinStatus = "0":---Call Function with Variables---NetGetJoinInfo(@Computername,$ComputerJoinedDomain,$ComputerDomainJoinStatus)If StringLeft($ComputerJoinedDomain,5) <> "Error" Then MsgBox(0,"Domain","ComputerDomain: " & $ComputerJoinedDomain) MsgBox(0,"Status","JoinedDomainStatus: " & $ComputerDomainJoinStatus)Else MsgBox(0,"Error",$ComputerJoinedDomain)EndIfExit;####################################################################################################Func NetGetJoinInfo($wkst, ByRef $JoinedDomain, ByRef $DomainJoinStatus)Local $err, $domStruct, $bufferType, $typStructIf StringLen($wkst) = 0 Then $wkst = @ComputernameIf StringLeft($wkst,2) <> "\\" Then $wkst = "\\" & $wkstLocal $domStruct = DllStructCreate("ptr"), $typStruct = DllStructCreate("int")DllCall("NetApi32.dll", "int" ,"NetGetJoinInformation", _ "int_ptr" ,$wkst , _ "ptr" ,DllStructGetPtr($domStruct) , _ "ptr" ,DllStructGetPtr($typStruct))If @error <> "0" Then $JoinedDomain="Error:" & @errorElse $JoinedDomain=DllStructGetData ($domStruct,1) $DomainJoinStatus=DllStructGetData ($typStruct,1)EndIfDllCall ("netapi32.dll", "int" ,"NetApiBufferFree", "ptr" , DllStructGetData ($domStruct,1) )EndFunc ;#################################################################################################### Link to comment Share on other sites More sharing options...
PaulIA Posted February 2, 2007 Share Posted February 2, 2007 Hello together,my appended Function returns the correct DomainJoinStatus, but the name is just a number ... why?Does someone has an idea why?Thanks in advanceJochenThe prototype for NetGetJoinInformation is:NET_API_STATUS NetGetJoinInformation( LPCWSTR lpServer, LPWSTR* lpNameBuffer, PNETSETUP_JOIN_STATUS BufferType)Those are Unicode strings, not ANSI strings. You'll need to convert the server name to Unicode before passing it to the function and then convert the name from Unicode to ANSI when the function returns. You'll need something like MultiByteToWideChar and WideCharToMultiByte for this. These functions are defined in the Auto3Lib A3LWinAPI module if you want to look at how they are implemented. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
PaulIA Posted February 2, 2007 Share Posted February 2, 2007 $a = DLLCall("netapi32.dll","int","NetGetJoinInformation","wstr",@computername,"int_ptr",0,"int_ptr",0) $b = DLLCall("kernel32.dll", "none", "RtlMoveMemory", "wstr", "", "ptr", $a[2], "int", 256) MsgBox(4096,$a[3],$b[1]) DLLCall("netapi32.dll","int","NetApiBufferFree","ptr",$B)I think you've got the wrong pointer in the last line. Should be $a[2] shouldn't it? Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
JSchmitt Posted February 5, 2007 Author Share Posted February 5, 2007 Thanks a lot to all helped me with that! Regards Jochen Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now