#### Archived

This topic is now archived and is closed to further replies.

# Where to put DLL so that web service can load it

This topic is 5199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have created a vc++.net web service. This web service should load a c++ dll at Load time. For this, i have copied my DLL in the Project folder(where my remaining web service code is). but my web service is not able to load this dll. Reason :: I have not put the DLL in the right path (or directory). But until now i have not figured out where should the DLL be put so that the web service is able to load it. If anybody can give some feedback on this, it will mean great help.

##### Share on other sites
Windows seems to like it if DLLs are located in the System32 folder. You could try putting a copy there.

if i am not mistaken, windows usually looks in these places (in this order, i think):

-Windows/System32
-Windows/System
-Windows
-The folder itself (normally it searches in the folder the Exe is located in too, wierd that it doesn''t)
-I read somewhere, that after all has failed, windows searches everywhere? But i doubt this.

Coding is a lifestyle,
Gaming an obsession

##### Share on other sites
Besides moving the .dll to the windows/system32 folder, there are a few ways you can keep it in the original folder instead if you want. Here are two off the top of my head:

- at install time, the installer can write to the registry (in HKEY_LOCAL_MACHINE\Software\(your company)\(your app) would be good) the location (full path) of the .dll. Then your service, when it wants to load the .dll, looks up the info in the registry and loads the .dll using the full path.

- if the .dll is in the same folder as your service executable: at run time, call GetModuleFileName to get the full path of the service executable. Strip of the everything after the last slash, and tack on the name of your .dll, giving you the full path to your .dll, which you can then load. Code:

    char dllpath[_MAX_PATH];    GetModuleFileName(NULL, dllpath, _MAX_PATH);  // get full path of currently running executable    char *cp = strrchr(dllpath, '\\');  // find the last slash    if(cp)        *cp = '\0';     // and trim it    strcat(dllpath, "\\mydll.dll"); // append the name of your .dll    HMODULE hDll = LoadLibrary(dllpath);

[edited by - BriTeg on March 30, 2004 11:36:38 AM]

##### Share on other sites
Thanks!
putting the DLL into System32 folder did it !

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×