NetWkstaUserGetInfo
-
hello all: when i use NetWkstaUserGetInfo function
typedef struct \_WKSTA\_USER\_INFO\_1 { LPWSTR wkui1\_username; LPWSTR wkui1\_logon\_domain; LPWSTR wkui1\_oth\_domains; LPWSTR wkui1\_logon\_server; }WKSTA\_USER\_INFO\_1, \*PWKSTA\_USER\_INFO\_1, \*LPWKSTA\_USER\_INFO\_1; \_WKSTA\_USER\_INFO\_1 t; char tm\[100\]={0}; NetWkstaUserGetInfo(NULL,1,(LPBYTE\*)(&t)); strcpy(tm,(char\*)t.wkui1\_username);
"65168" is the t.wkui1_username value why is not the current user name?
a beginner
-
hello all: when i use NetWkstaUserGetInfo function
typedef struct \_WKSTA\_USER\_INFO\_1 { LPWSTR wkui1\_username; LPWSTR wkui1\_logon\_domain; LPWSTR wkui1\_oth\_domains; LPWSTR wkui1\_logon\_server; }WKSTA\_USER\_INFO\_1, \*PWKSTA\_USER\_INFO\_1, \*LPWKSTA\_USER\_INFO\_1; \_WKSTA\_USER\_INFO\_1 t; char tm\[100\]={0}; NetWkstaUserGetInfo(NULL,1,(LPBYTE\*)(&t)); strcpy(tm,(char\*)t.wkui1\_username);
"65168" is the t.wkui1_username value why is not the current user name?
a beginner
alphaxz wrote:
char tm[100]={0}; NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t)); strcpy(tm,(char*)t.wkui1_username);
Since Unicode is defined, why not use:
TCHAR tm[100] = {0};
NetWkstaUserGetInfo(NULL, 1, (LPBYTE *) (&t));
_tcscpy_s(tm, _countof(tm), t->wkui1_username);alphaxz wrote:
why is not the current user name?
Because
t
should be a pointer instead:LPWKSTA_USER_INFO_1 t;
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
alphaxz wrote:
char tm[100]={0}; NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t)); strcpy(tm,(char*)t.wkui1_username);
Since Unicode is defined, why not use:
TCHAR tm[100] = {0};
NetWkstaUserGetInfo(NULL, 1, (LPBYTE *) (&t));
_tcscpy_s(tm, _countof(tm), t->wkui1_username);alphaxz wrote:
why is not the current user name?
Because
t
should be a pointer instead:LPWKSTA_USER_INFO_1 t;
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
I can't understand what do you mean? a struct or a point to a struct ,any difference?
a beginner
Just take a look at the below piece of code and hope you will be clear.. DWORD dwLevel = 1; // Specifies the information level of the data LPWKSTA_USER_INFO_1 pBuf = NULL; NetWkstaUserGetInfo(NULL, dwLevel, (LPBYTE *)&pBuf); The 3rd parameter is the pointer to the buffer that holds the data. A point to note here is that this function will work only locally and will fail if you try to enumerate the list of remote users... Regards, Rane
-
Just take a look at the below piece of code and hope you will be clear.. DWORD dwLevel = 1; // Specifies the information level of the data LPWKSTA_USER_INFO_1 pBuf = NULL; NetWkstaUserGetInfo(NULL, dwLevel, (LPBYTE *)&pBuf); The 3rd parameter is the pointer to the buffer that holds the data. A point to note here is that this function will work only locally and will fail if you try to enumerate the list of remote users... Regards, Rane
-
I can't understand what do you mean? a struct or a point to a struct ,any difference?
a beginner
alphaxz wrote:
I can't understand what do you mean?
I gave you the code. What's not to understand?
alphaxz wrote:
a struct or a point to a struct ,any difference?
Yes, a big one. Notice the third argument to
NetWkstaUserGetInfo()
is supposed to be aBYTE**
. The second pointer is there so thatNetWkstaUserGetInfo()
can allocate memory for the structure. Don't forget to callNetApiBufferFree()
."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
alphaxz wrote:
I can't understand what do you mean?
I gave you the code. What's not to understand?
alphaxz wrote:
a struct or a point to a struct ,any difference?
Yes, a big one. Notice the third argument to
NetWkstaUserGetInfo()
is supposed to be aBYTE**
. The second pointer is there so thatNetWkstaUserGetInfo()
can allocate memory for the structure. Don't forget to callNetApiBufferFree()
."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch