Since sample.exe
is your own application, you can troubleshoot the problem by adding logging code. For example:
- Call SHGetKnownFolderPath to determine the application data folder.
- Call GetUserName to check what user account you are running under.
- Call GetEnvironmentStrings to determine how the environment variables are set, paying particular attention to %APPDATA% and %LOCALAPPDATA%.
- If this is a C program, use getenv("APPDATA") and getenv("LOCALAPPDATA") as well; IIRC, the C runtime library keeps it's own copy of the environment variables.
If the application data folder is correct but the environment variable isn't (this would be my first guess as to the problem) then you can try using SetEnvironmentVariable and/or _putenv to correct the path before loading the external library.