Declare + Debugbuild

I’m using a local dll (in the same folder than the exe)

Const SGL_Lib As String = "SglW32.dll" Soft Declare Function SglAuthentA Lib SGL_Lib (AuthentCode As Ptr, AppRandNum As Ptr, LibRandNum As Ptr) As UInt32
But when I am in Debigbuild mode the dll is not in the Debug folder, so it is not found.
Can I change the dll name just for Debugbuild mode ?

If Debugbuild Then.... doesn’t work because dll name must be a constant.
TIA

Perhaps, a copy files step in the build would be useful here. It will also help with the deployment later on.

Use the compiler pragma version of IF

#IF DebugBuild …

Copy the DLL next to the executable with a copy file build step, after the gear. That way it will always be next to the EXE, no matter debug or not.

Thanks to all.
Today I will try to apply one of these solutions and I’ll inform you later.

[quote=289832:@Tim Hare]Use the compiler pragma version of IF

Thanks Tim. This works:

[code]#if DebugBuild Then 
  Soft Declare Function SglAuthentA Lib "..\\SglW32.dll" (AuthentCode As Ptr, AppRandNum As Ptr, LibRandNum As Ptr) As UInt32
  Soft Declare Function SglAuthentB Lib "..\\SglW32.dll" (LibRandNum As Ptr) As UInt32
#else
  Soft Declare Function SglAuthentA Lib "SglW32.dll" (AuthentCode As Ptr, AppRandNum As Ptr, LibRandNum As Ptr) As UInt32
  Soft Declare Function SglAuthentB Lib "SglW32.dll" (LibRandNum As Ptr) As UInt32
#endif[/code]

[quote=289863:@Michel Bujardet]Copy the DLL next to the executable with a copy file build step, after the gear. That way it will always be next to the EXE, no matter debug or not.[/quote]

Thanks Michel for your answer, but I don’t understand:
When I’m debugging I don’t have the EXE yet. So how can I copy it there?
When you say “after the gear”. Where is this?
Sorry for my ignorance.

[quote=289793:@jean-paul devulder]You can try load yourself the library before use
Declare Function LoadLibrary Lib “kernel32” Alias “LoadLibraryA”(lpLibFileName As CString) As Integer[/quote]

Jean-Paul and Louis,
Thanks for your suggestions. Now it already works, but I’ll try your ways just to learn more.

[quote=289925:@Ramon SASTRE]When I’m debugging I don’t have the EXE yet. So how can I copy it there?
When you say “after the gear”. Where is this?
Sorry for my ignorance.[/quote]

No need to be sorry.

The gear appears in the build settings, in “Windows”. Click the disclosure triangle and you will see it. Place the copyfile under the gear. That is the moment when the exe is created, so placing the copy afterward will copy it next to the newly built exe.

That is also that way you can copy any needed DLL to have them, especially the VC redistribuable ones for 2016R3.

[quote=289928:@Michel Bujardet]No need to be sorry.

The gear appears in the build settings, in “Windows”. Click the disclosure triangle and you will see it. Place the copyfile under the gear. That is the moment when the exe is created, so placing the copy afterward will copy it next to the newly built exe.

That is also that way you can copy any needed DLL to have them, especially the VC redistribuable ones for 2016R3.[/quote]

Thanks Michel.
I’d never seen this. Wow! There is so much to learn yet.

BTW when you use the copyfile, no need to the if TargetBuild as posted above.