Discussion:
Shortcut working directory
(too old to reply)
Janiv Ratson
2006-01-31 09:47:19 UTC
Permalink
Hello,
I have an MDI application which supports doeble clicking on an NFG file to
open the file.
However, it works only for NFG files that located on the same directory with
the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot run,
becuase it cannot find some dllz required for the application to run.

I set the application path in the regisrtry, so if I put the exe file in any
folder and double click it it works. I want the same beahviour for opening
an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
jSmith
2006-01-31 18:34:08 UTC
Permalink
Post by Janiv Ratson
Hello,
I have an MDI application which supports doeble clicking on an NFG file to
open the file.
However, it works only for NFG files that located on the same directory with
the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot run,
becuase it cannot find some dllz required for the application to run.
I set the application path in the regisrtry, so if I put the exe file in any
folder and double click it it works. I want the same beahviour for opening
an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
Try something like this:

TCHAR ModuleFileName[MAX_PATH+1];
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
CString dll_location = ModuleFileName;
dll_location = dll_location.Left(dll_location.ReverseFind(_T('\\'))+1);
dll_location += _T("MY.DLL");

HMODULE hModule = ::LoadLibrary(dll_location);
Janiv Ratson
2006-02-12 15:10:27 UTC
Permalink
I cannot use LoadLibrary, becuase I'm using many 3rd party dllz.
I don't want my application to be dependent on others dlls.
Also there are too many dllz to use LoadLibrary for (about 30 dllz !!!).
Please help,
If there is any solution ....

I'll try to explain my problem again:

When I double Click on an NFG file (which is a doc template in my app, and
yes, I'm using RegisterShellFileTypes(true); - that is the reason it works
when you double click an NFG file that is located in the location with my
EXE file).
Some dll cannot be located.

If I double click on a shortcut to my applicaiton located on the Desktop it
works.
If I double click on a shortcut to an NFG file that is located in my EXE
fiile directory, it works.
If I double click on a shortcut to an NFG file that is located somewhere
else, it displays a message about it cannot find a dll.

Thanks again,
Janiv Ratson.
Post by jSmith
Post by Janiv Ratson
Hello,
I have an MDI application which supports doeble clicking on an NFG file
to open the file.
However, it works only for NFG files that located on the same directory
with the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot
run, becuase it cannot find some dllz required for the application to
run.
I set the application path in the regisrtry, so if I put the exe file in
any folder and double click it it works. I want the same beahviour for
opening an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
TCHAR ModuleFileName[MAX_PATH+1];
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
CString dll_location = ModuleFileName;
dll_location = dll_location.Left(dll_location.ReverseFind(_T('\\'))+1);
dll_location += _T("MY.DLL");
HMODULE hModule = ::LoadLibrary(dll_location);
Mohammad Shalabi
2006-03-08 00:36:10 UTC
Permalink
can you try to add the path for these dll's to the PATH environment
variable?



Thank you.
Post by Janiv Ratson
I cannot use LoadLibrary, becuase I'm using many 3rd party dllz.
I don't want my application to be dependent on others dlls.
Also there are too many dllz to use LoadLibrary for (about 30 dllz !!!).
Please help,
If there is any solution ....
When I double Click on an NFG file (which is a doc template in my app, and
yes, I'm using RegisterShellFileTypes(true); - that is the reason it works
when you double click an NFG file that is located in the location with my
EXE file).
Some dll cannot be located.
If I double click on a shortcut to my applicaiton located on the Desktop
it works.
If I double click on a shortcut to an NFG file that is located in my EXE
fiile directory, it works.
If I double click on a shortcut to an NFG file that is located somewhere
else, it displays a message about it cannot find a dll.
Thanks again,
Janiv Ratson.
Post by jSmith
Post by Janiv Ratson
Hello,
I have an MDI application which supports doeble clicking on an NFG file
to open the file.
However, it works only for NFG files that located on the same directory
with the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot
run, becuase it cannot find some dllz required for the application to
run.
I set the application path in the regisrtry, so if I put the exe file in
any folder and double click it it works. I want the same beahviour for
opening an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
TCHAR ModuleFileName[MAX_PATH+1];
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
CString dll_location = ModuleFileName;
dll_location = dll_location.Left(dll_location.ReverseFind(_T('\\'))+1);
dll_location += _T("MY.DLL");
HMODULE hModule = ::LoadLibrary(dll_location);
Ben Voigt
2006-03-15 23:01:16 UTC
Permalink
One reasonable way to help your program find load-time DLLs would be to
create a trampoline which sets the current directory, then launches your
true process passing along the command-line.
Post by Mohammad Shalabi
can you try to add the path for these dll's to the PATH environment
variable?
Thank you.
Post by Janiv Ratson
I cannot use LoadLibrary, becuase I'm using many 3rd party dllz.
I don't want my application to be dependent on others dlls.
Also there are too many dllz to use LoadLibrary for (about 30 dllz !!!).
Please help,
If there is any solution ....
When I double Click on an NFG file (which is a doc template in my app,
and yes, I'm using RegisterShellFileTypes(true); - that is the reason it
works when you double click an NFG file that is located in the location
with my EXE file).
Some dll cannot be located.
If I double click on a shortcut to my applicaiton located on the Desktop
it works.
If I double click on a shortcut to an NFG file that is located in my EXE
fiile directory, it works.
If I double click on a shortcut to an NFG file that is located somewhere
else, it displays a message about it cannot find a dll.
Thanks again,
Janiv Ratson.
Post by jSmith
Post by Janiv Ratson
Hello,
I have an MDI application which supports doeble clicking on an NFG file
to open the file.
However, it works only for NFG files that located on the same directory
with the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot
run, becuase it cannot find some dllz required for the application to
run.
I set the application path in the regisrtry, so if I put the exe file
in any folder and double click it it works. I want the same beahviour
for opening an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
TCHAR ModuleFileName[MAX_PATH+1];
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
CString dll_location = ModuleFileName;
dll_location = dll_location.Left(dll_location.ReverseFind(_T('\\'))+1);
dll_location += _T("MY.DLL");
HMODULE hModule = ::LoadLibrary(dll_location);
Tom Serface
2006-01-31 20:38:15 UTC
Permalink
I'm not sure what an NFG files is exactly, but you should look at:

RegisterShellFileTypes(true);

As this will register your document type with explorer for your application.
The user will have to have permission to change the registry for
HKEY_CLASSES_ROOT (which means not a totally Limited User).

Tom
Post by Janiv Ratson
Hello,
I have an MDI application which supports doeble clicking on an NFG file to
open the file.
However, it works only for NFG files that located on the same directory
with the ConfigNet.exe file name.
For NFG that are located in different folders, the application cannot run,
becuase it cannot find some dllz required for the application to run.
I set the application path in the regisrtry, so if I put the exe file in
any folder and double click it it works. I want the same beahviour for
opening an NFG file (by double clicking it).
Thanks,
Janiv Ratson.
Continue reading on narkive:
Loading...