ManagedDism icon indicating copy to clipboard operation
ManagedDism copied to clipboard

How to customize the path of dismapi.dll or dism.exe ?

Open i2i8 opened this issue 3 years ago • 3 comments

I want to use a custom path dismapi.dll, such as D:\lib\dismapi.dll, how to load when Winform is initialized?

i2i8 avatar Jul 09 '22 22:07 i2i8

I'm pretty sure you can place dismapi.dll next to your app in a x86 and x64 folder. If your application is AnyCPU, a 32-bit machine will look for native assemblies in the x86 folder and a 64-bit machine will look in the x64 folder.

That said, I'm not sure if you're allowed to redistribute dismapi.dll as the official documentation indicates that installing the Windows Asset and Deployment Kit is required.

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/using-the-dism-api?view=windows-11#requirements

jeffkl avatar Jul 11 '22 17:07 jeffkl

I'm sure it's possible to customize the path to dismapi.dll. For example, I copied the folder C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\ AMd64 \DISM and its subdirectories, and then, Dismapi.dll can be used in any directory, such as: D:\DISM, even if ADK is not installed on the system. I just don't know how to load diskapi.dll custom in ManagedDism.

i2i8 avatar Jul 11 '22 17:07 i2i8

if you place Microsoft.Dism.dll in the same directory with the custom DISM path, it will auto load dismapi.dll from that path just make sure to use DismApi.Initialize not DismApi.InitializeEx

you can also do it manually P/Invoke LoadLibrary dismapi.dll from the custom path, use DismApi.Initialize, then at last P/Invoke FreeLibrary

stdin82 avatar Oct 29 '22 18:10 stdin82