Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
recuperation du nom de domaine... à tester
Function ulong NetGetDCName( & char servername[], & char domainname[], & ref ulong bufptr & ) Library "netapi32.dll" Alias for "NetGetDCName"
creer ensuite 2 fonctions.
of_string_to_unicode (string as_string, ref character ac_unicode[]);// convert string to unicode char array
Integer li_loop, li_len, li_uni li_len = Len(as_string) FOR li_loop = 1 TO li_len li_uni = li_uni + 1 ac_unicode[li_uni] = Mid(as_string, li_loop, 1) li_uni = li_uni + 1 ac_unicode[li_uni] = Char(0) NEXT li_uni = li_uni + 1 ac_unicode[li_uni] = Char(0) li_uni = li_uni + 1 ac_unicode[li_uni] = Char(0)
function string of_unicode_to_string (unsignedlong aul_ptr);// get a string from a pointer to a unicode string
Char lc_byte Integer li_loop String ls_string lc_byte = String(aul_ptr, "address") DO WHILE Asc(lc_byte) > 0 ls_string += String(lc_byte) li_loop = li_loop + 2 lc_byte = String(aul_ptr + li_loop, "address") LOOP Return ls_string
on lance le script...
String ls_dcname, ls_msg ULong lul_result, lul_bufptr Char lc_server[], lc_domain[] // convert arguments to unicode of_string_to_unicode("", lc_server) of_string_to_unicode("", lc_domain) // call function to get DC name lul_result = NetGetDCName(lc_server, lc_domain, lul_bufptr) If lul_result = 0 Then // get string from buffer ls_dcname = of_unicode_to_string(lul_bufptr) // free buffer End If messagebox ("Nom de domaine",ls_dcname)
Hors ligne