GetUserNameEx

This is a discussion on GetUserNameEx within the C++ Programming forums, part of the General Programming Boards category; I am trying to use the GetUserNameEx function, and my code compiles, but when I build it, I get this ...

  1. #1
    Unregistered
    Guest

    Question GetUserNameEx

    I am trying to use the GetUserNameEx function, and my code compiles, but when I build it, I get this error:

    Cpp1.obj : error LNK2001: unresolved external symbol "unsigned char __stdcall GetUserNameExA(enum EXTENDED_NAME_FORMAT,char *,unsigned long *)" (?GetUserNameExA@@YGEW4EXTENDED_NAME_FORMAT@@PADPA K@Z)
    Release/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Am I missing a library?
    Does anyone have any suggestions?

  2. #2
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    Well....

    It seems like you are using an unsigned variable and you can't. Are you? Try giving it a value right away and then it will be overwritten later.

  3. #3
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    On MSDN it states you have to link with Secur32.lib, have you added this library? Also it's only for nt/2k etc not 9x.
    zen

  4. #4
    Unregistered
    Guest
    Thank you for the tips.
    I see what you mean about the Secur32.lib.
    How do I link to it? Is it included in the
    Secur32.dll?

  5. #5
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You just add "Secur32.lib" to the Object/Library Modules edit box on the link tab of the Project Settings. This library appears to be a fairly recent addition to the API so you may need an updated Platform SDK from the MS site if Secur32.lib isn't in your standard lib directory.
    zen

  6. #6
    Unregistered
    Guest
    I just downloaded the SDK and got secur32.lib.
    I added it into my \lib directory, but I am still getting the same error as before. Any more ideas?

  7. #7
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    I just tried it and it linked fine. Have you linked to Secur32.lib in your project settings?
    zen

  8. #8
    Unregistered
    Guest

    Talking

    Thanks for all of your help!
    I finally got it to work...
    I included too many header files.
    The one that was causing the problem was SSPI.H

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 'GetUserNameEx': identifier not found error
    By shivarajbm in forum Windows Programming
    Replies: 13
    Last Post: 09-02-2010, 12:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21