Prabath Yapa
Prabath Yapa

Reputation: 1229

Pinvoke - Location of the Win32 DLL

I use PInvoke on a win32 DLL and i've currently placed it in my System32 folder. Is there an alternative to this? What if my app needs to be deployed somewhere where i dont have access to system folders?

Upvotes: 0

Views: 828

Answers (2)

Kate Gregory
Kate Gregory

Reputation: 18964

Please don't put it in System32. You will make your install more complicated than it needs to be. Just put it in the same folder as the exe. Save System32 for, you know, system stuff.

Upvotes: 3

Steve Townsend
Steve Townsend

Reputation: 54168

So long as the DLL is present somewhere on the Path that is used by the app, it should get loaded properly. The approach you have described here works because of this trait: System32 is always in the path.

Here is some more info on how DLLs are located for loading. Your app can know its own path via

System.Environment.GetEnvironmentVariable("Path");

Upvotes: 4

Related Questions