Driver ODBC Oracle lead LoadLibrary to error ERROR_MOD_NOT_FOUND

Issue

I Have the following architecture :

Program A

=> CreateProcess 'program B'

   => Wait for program B to end

=> SQLConnect

   => Wait for SQLConnect to end

=> CreateProcess 'program B'

   => Wait for program B to end

My Program B is a very simple exe who basiclly only do a LoadLibrary

Before SQLConnect the LoadLibrary of program B succeed

After SQL Connect it fails with error 126 ERROR_MOD_NOT_FOUND

I Have no clue of what is going one here.

Program A is coded with WinDev, Program B is coded in C, Operating System is Windows 10 x64.

I would take any lead.

Thanks for your help.

Solution

The ODBC driver does a call to SetDllDirectory which change the dll path where windows is looking and leading LoadLibrary to fail.

Apparently this setup is inherited by the child process, even if it does not appear on the env.

An easy fix was to call a SetDllDirectory(NULL) at the begining of the child process.

Answered By – damjuve

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published