Is it possible to set fixed DLL search path in VisualStudio application?

593 Views Asked by At

I have a Qt/VisualStudio application which should start from a removable device without installation. I want to place in the root directory only the executable and all the required DLLs in in a directory "data".

The executable should load the DLLs from "data", but no path to "data" should be set before. The DLL search-path should be hard coded in the exe and it should be (only) ".\data"

Is it possible? I'm using VS2008. I've read the documantation on each linker-parameter, but have not identified a proper yet.

1

There are 1 best solutions below

2
Valentin H On

As mvidelgauz suggested, I've implemented a launcher using winapi. It was my first native winapi project, but it took indeed only halh an hour to implement.

  1. I created a default Win32 project in VS2008.

  2. In BOOL InitInstance(HINSTANCE hInstance, int nCmdShow), removed the lines:

    //ShowWindow(hWnd, nCmdShow);
    //UpdateWindow(hWnd);
    
  3. And then instead of them, I added:

    SetCurrentDirectory( L"MyPath" );
    ShellExecute(hWnd, NULL, L"MyApp.exe", L"-l", NULL, SW_HIDE);
    DestroyWindow(hWnd);