Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. NetWkstaUserGetInfo

NetWkstaUserGetInfo

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alphaxz
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A alphaxz

      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

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • D David Crow

        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

        A Offline
        A Offline
        alphaxz
        wrote on last edited by
        #3

        I can't understand what do you mean? a struct or a point to a struct ,any difference?

        a beginner

        R D 2 Replies Last reply
        0
        • A alphaxz

          I can't understand what do you mean? a struct or a point to a struct ,any difference?

          a beginner

          R Offline
          R Offline
          Rane
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • R 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

            A Offline
            A Offline
            alphaxz
            wrote on last edited by
            #5

            thanks all I've got the answer the difference between ansi and unicode

            a beginner

            1 Reply Last reply
            0
            • A alphaxz

              I can't understand what do you mean? a struct or a point to a struct ,any difference?

              a beginner

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              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 a BYTE**. The second pointer is there so that NetWkstaUserGetInfo() can allocate memory for the structure. Don't forget to call NetApiBufferFree().

              "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

              A 1 Reply Last reply
              0
              • D David Crow

                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 a BYTE**. The second pointer is there so that NetWkstaUserGetInfo() can allocate memory for the structure. Don't forget to call NetApiBufferFree().

                "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

                A Offline
                A Offline
                alphaxz
                wrote on last edited by
                #7

                thank u very much i've got the answer under your instruction

                a beginner

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups