Hello,
I'm trying to convert my VB6 code to VB .NET.
I have a call to the NetUserGetInfo API which populates the USER_INFO_3 structure as below:-
What do these integer values actually hold? Are they pointers in memory? and how do I convert these integer values to the correpsonding string values?Code:Public Structure USER_INFO_3 Dim usri3_name As Integer Dim usri3_password As Integer Dim usri3_password_age As Integer Dim usri3_priv As Integer Dim usri3_home_dir As Integer Dim usri3_comment As Integer Dim usri3_flags As Integer Dim usri3_script_path As Integer Dim usri3_auth_flags As Integer Dim usri3_full_name As Integer Dim usri3_usr_comment As Integer Dim usri3_parms As Integer Dim usri3_workstations As Integer Dim usri3_last_logon As Integer Dim usri3_last_logoff As Integer Dim usri3_acct_expires As Integer Dim usri3_max_storage As Integer Dim usri3_units_per_week As Integer Dim usri3_logon_hours As Byte Dim usri3_bad_pw_count As Integer Dim usri3_num_logons As Integer Dim usri3_logon_server As Integer Dim usri3_country_code As Integer Dim usri3_code_page As Integer Dim usri3_user_id As Integer Dim usri3_primary_group_id As Integer Dim usri3_profile As Integer Dim usri3_home_dir_drive As Integer Dim usri3_password_expired As Integer End Structure
I've looked at the GetStrFromPtrW function that I've used in the VB6 version, without any success??
The values that I am getting back are totally incorrect at the moment and this is beginning to frustrate.Code:Public Function GetStrFromPtrW(ByRef lpszW As Integer) As String Dim sRtn As Integer Dim WideChar As Integer sRtn = lstrlenW(lpszW) ' 2 bytes/char ' WideCharToMultiByte also returns Unicode string length WideChar = WideCharToMultiByte(CP_ACP, 0, lpszW, -1, sRtn, _ vbNullString, vbNullString, 0) GetStrFromPtrW = GetStrFromBufferA(sRtn) End Function ' Returns the string before first null char encountered (if any) from an ANSII string. Public Function GetStrFromBufferA(ByRef sz As String) As String If InStr(sz, vbNullChar) Then GetStrFromBufferA = Left$(sz, InStr(sz, vbNullChar) - 1) Else ' If sz had no null char, the Left$ function ' above would return a zero length string (""). GetStrFromBufferA = sz End If End Function
Any help would be appreciated.




Reply With Quote