5

I am building a small application in C# that can create the user profile on Windows XP, Windows7 and Windows 8, using the Windows APIs

For Windows 7 and 8, the method CreateProfile worked perfectly.

But, when trying to use the CreateUserProfileEx on Windows XP, it didn't work, it returned me an error notifying that the method couldn't be find in the "UserEnv.dll", after reading a little bit more the API, I realized that I would need to use the LoadLibrary and GetProcAddress to link to Userenv.dll.

I searched for some sample related to this, but I couldn't find something that could give me a good idea or explanation how to do this.

if someone could put some sample in C# or point me where I could review about this, I would really appreciate it.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
jfvf
  • 53
  • 4
  • There are examples of this, for a different API but the process is the same for all Win32 APIs, here on [SO]: http://stackoverflow.com/questions/3754264/c-sharp-getprocaddress-returns-zero – Richard Jun 29 '14 at 08:57

1 Answers1

5

after reading a little bit more the API, I realized that I would need to use the LoadLibrary and GetProcAddress to link to Userenv.dll.

Read a little bit more:

This function is not declared in the software development kit (SDK) headers and has no associated import library. You must use the LoadLibrary and GetProcAddress functions to link to Userenv.dll. The ANSI version of the function, CreateUserProfileExA is referenced from Userenv.dll as ordinal 153. The Unicode version, CreateUserProfileExW is referenced as ordinal 154.

Google a little bit:

Additionally, in Windows you can bind to exported DLL functions by their ordinal values. If you need to do this, an EntryPoint value such as "#1" or "#129" indicates the ordinal value of the unmanaged function in the DLL rather than a function name.

ta.speot.is
  • 26,914
  • 8
  • 68
  • 96