我正在用 C# 构建一个小型应用程序,它可以使用 Windows API 在 Windows XP、Windows7 和 Windows 8 上创建用户配置文件
对于 Windows 7 和 8,方法 CreateProfile
工作完美。
但是,当尝试使用 CreateUserProfileEx
在 Windows XP 上,它不起作用,它返回一个错误,通知我在“UserEnv.dll”中找不到该方法,在阅读了更多 API 之后,我意识到我需要使用LoadLibrary
和 GetProcAddress
链接到 Userenv.dll。
我搜索了一些与此相关的示例,但找不到可以给我一个好主意或解释如何执行此操作的内容。
如果有人可以在 C# 中放置一些示例或指出我可以查看的地方,我将非常感激。
最佳答案
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.
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.
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.
关于c# - 如何在 C# 中使用 CreateUserProfileEx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24474445/