Different folder of exe and dll

Hi,
I have an .exe file which uses a .dll that is not located in the same folder 
of the .exe.
I do not want to add to the search path the directory where the .dll exists.
How can I do it ? Manifest ? How should i create Manifest and update it with 
the desired dll path??

Yoav. 


0
yoav (105)
7/22/2008 8:12:19 AM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
797 Views

Similar Articles

[PageSpeed] 53

[Yoavo]

> I have an .exe file which uses a .dll that is not located in the same 
> folder of the .exe.
> I do not want to add to the search path the directory where the .dll 
> exists.
> How can I do it ? Manifest ? How should i create Manifest and update it 
> with the desired dll path??

You may want to use LoadLibrary and specify the path of your DLL.
In that case you should use GetProcAddress to access DLL functions (of 
course, it is possible only for pure C interface DLLs).

Unfortunately, about manifests, it seems that proper detailed documentation 
is hard to find...

Giovanni



0
Giovanni
7/22/2008 10:57:05 AM
Hi,
I can not use LoadLibrary since the dll need to be pre-loaded.

"Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it> wrote in message 
news:ej6N7o%236IHA.5292@TK2MSFTNGP02.phx.gbl...
>
> [Yoavo]
>
>> I have an .exe file which uses a .dll that is not located in the same 
>> folder of the .exe.
>> I do not want to add to the search path the directory where the .dll 
>> exists.
>> How can I do it ? Manifest ? How should i create Manifest and update it 
>> with the desired dll path??
>
> You may want to use LoadLibrary and specify the path of your DLL.
> In that case you should use GetProcAddress to access DLL functions (of 
> course, it is possible only for pure C interface DLLs).
>
> Unfortunately, about manifests, it seems that proper detailed 
> documentation is hard to find...
>
> Giovanni
>
>
> 


0
yoav (105)
7/22/2008 12:46:07 PM
Then it cannot be done.

If you don't use PATH (which is always a bad idea in this situation) then your only
choices are to put it in the same folder as the executable, or to use LoadLibrary.

Why does it have to be pre-loaded?  That assumption may be the one you have to change to
make this work.
				joe

On Tue, 22 Jul 2008 15:46:07 +0300, "Yoavo" <yoav@cimatron.co.il> wrote:

>Hi,
>I can not use LoadLibrary since the dll need to be pre-loaded.
>
>"Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it> wrote in message 
>news:ej6N7o%236IHA.5292@TK2MSFTNGP02.phx.gbl...
>>
>> [Yoavo]
>>
>>> I have an .exe file which uses a .dll that is not located in the same 
>>> folder of the .exe.
>>> I do not want to add to the search path the directory where the .dll 
>>> exists.
>>> How can I do it ? Manifest ? How should i create Manifest and update it 
>>> with the desired dll path??
>>
>> You may want to use LoadLibrary and specify the path of your DLL.
>> In that case you should use GetProcAddress to access DLL functions (of 
>> course, it is possible only for pure C interface DLLs).
>>
>> Unfortunately, about manifests, it seems that proper detailed 
>> documentation is hard to find...
>>
>> Giovanni
>>
>>
>> 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
7/22/2008 2:24:32 PM
>I have an .exe file which uses a .dll that is not located in the same folder 
>of the .exe.
>I do not want to add to the search path the directory where the .dll exists.
>How can I do it ?

Have a look at "App Paths" in MSDN (see the "PerceivedTypes,
SystemFileAssociations, and Application Registration" topic). That may
allow you to do what you need, though personally I'd just put the DLL
in the same directory as the EXE.

Dave
0
davidl7375 (2060)
7/22/2008 4:19:30 PM
There are problems with "App Paths".  For example, they only come into play if you launch
using ShellExecute (note that double-clicking an icon for the program or double-clicking
it in a directory display indeed *does* do this), and it places the app path at the END of
that PATH= list.  So suppose I called my DLL "util.dll".  If there is a "util.dll"
anywhere in the path PRIOR to hitting the specified app path, then that DLL will be
loaded, and THEN the failure to resolve external addresses will occur and the execution
will be terminated.  This produces a complex tech support call (I've done them!) and
usually involves a complex solution (and sometimes no solution is possible).  Overall, any
dependence on PATH= is an invitation to total flaming support disaster.  I'd rather do an
explict LoadLibrary than to use  path.  Using this technique, it means that there is no
question about where the library comes from.

Note that for XP SP2, there is the local path redirection as well, but the key here is the
assertion by the OP that the DLL must be "pre-loaded".  It doesn't take too much effort to
eliminate that requirement, but a flat statement that this is not acceptable means that
there is no feasible solution that will not ultimately be a support nightmare.  Of course,
PATH= can be used with lower risk if you name the DLL using a GUID, but LoadLibrary is not
all that big a hassle and there is rarely a requirement that the library be pre-loaded;
I'd like to have the OP comment on why this is a necessary requirement.  Generally it only
takes a simple change in the header file to switch between static linking, implicit
dynamic linking and explicit dynamic linking, plus a bit of support code for the latter
case to do the GetProcAddress resolution.
					joe

On Tue, 22 Jul 2008 17:19:30 +0100, David Lowndes <DavidL@example.invalid> wrote:

>>I have an .exe file which uses a .dll that is not located in the same folder 
>>of the .exe.
>>I do not want to add to the search path the directory where the .dll exists.
>>How can I do it ?
>
>Have a look at "App Paths" in MSDN (see the "PerceivedTypes,
>SystemFileAssociations, and Application Registration" topic). That may
>allow you to do what you need, though personally I'd just put the DLL
>in the same directory as the EXE.
>
>Dave
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
7/22/2008 7:39:05 PM
On Tue, 22 Jul 2008 15:39:05 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

>There are problems with "App Paths".

That's an understatement. While trying to install VS.NET 2003, the Epson
Copy Utility appeared first thing after I clicked "Prerequisites" in the
VS.NET installer. Dismissing that program caused VS.NET setup to silently
end as well. Why? It turns out that Epson installed a registry key named
"setup.exe" under "App Paths", that looks like this:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\setup.exe]
"RunAsOnNonAdminInstall"=dword:00000001
"BlockOnTSNonInstallMode"=dword:00000001
"Path"="C:\\Program Files\\EPSON\\Utility Suite\\Copy Utility"
@="C:\\Program Files\\EPSON\\Utility Suite\\Copy Utility\\ECOPY.exe"

This caused the VS.NET installer to run the "ecopy.exe" program it found
there, and deleting this key was the answer. Just the other day, I
installed a bloated driver set for a sound card, and partway through, I had
to dismiss one of my HP printer programs. Silly me, I forgot to clear my
"App Paths", which contained entries for "install.exe" and "setup.exe".

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
7/22/2008 8:01:26 PM
It is mind-boggling that there would be a programmer who is so incompetent as to modify
app paths for a program as common as "setup" or "install".  But what I've found among too
many programmers is that "hack it until it works" on an isolated machine is the norm, with
no thought as to the implications in real environments.  We need a "green" rating for
software, as in "is it ecosystem-friendly?"

Which goes back to a principle I developed by 1980: "Paths are evil".  

As a concept, their very existence is offensive.  They were a hack designed to compensate
for hopelessly inadequate designs of early toy operating systems (mainframe operating
systems in the 1970s were often less sophisticated than MS-DOS).  I had my first "path"
failure in INCLUDE paths in 1968, and had already known about failures in execution path
logic in 1967, and in those 40 years, as far as I can tell, nothing has changed--it was a
BAD idea (that's an acronym: Broken As Designed).

[One of the early hacks that allowed an application to gain kernel privileges in OS/360
was a path hack, and it was invented in 1966...by the time I leared about it in 1967 it
was a well-known hack]
					joje

On Tue, 22 Jul 2008 15:01:26 -0500, "Doug Harrison [MVP]" <dsh@mvps.org> wrote:

>On Tue, 22 Jul 2008 15:39:05 -0400, Joseph M. Newcomer
><newcomer@flounder.com> wrote:
>
>>There are problems with "App Paths".
>
>That's an understatement. While trying to install VS.NET 2003, the Epson
>Copy Utility appeared first thing after I clicked "Prerequisites" in the
>VS.NET installer. Dismissing that program caused VS.NET setup to silently
>end as well. Why? It turns out that Epson installed a registry key named
>"setup.exe" under "App Paths", that looks like this:
>
>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
>Paths\setup.exe]
>"RunAsOnNonAdminInstall"=dword:00000001
>"BlockOnTSNonInstallMode"=dword:00000001
>"Path"="C:\\Program Files\\EPSON\\Utility Suite\\Copy Utility"
>@="C:\\Program Files\\EPSON\\Utility Suite\\Copy Utility\\ECOPY.exe"
>
>This caused the VS.NET installer to run the "ecopy.exe" program it found
>there, and deleting this key was the answer. Just the other day, I
>installed a bloated driver set for a sound card, and partway through, I had
>to dismiss one of my HP printer programs. Silly me, I forgot to clear my
>"App Paths", which contained entries for "install.exe" and "setup.exe".
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
7/22/2008 9:38:39 PM
Reply:

Similar Artilces:

Compact Archive Folder in Outlook 2000
How do I compact the Archive folder in Outlook 2000? I deleted a lot of messages in it but the size has not changed. Using Advanced Personal Folders properties does not seem to compact the archive. Roger Why don't you start using a new archive file? What is the current size of the archive file? Try to keep your .pst files under 2 GB. Roger wrote: > How do I compact the Archive folder in Outlook 2000? I deleted a lot of > messages in it but the size has not changed. Using Advanced Personal > Folders properties does not seem to compact the archive. > > Roger The...

mdbperf.dll
Today I' ve installed EXBPA (best practices analyzer /italian version) and I've performed all the tests. I can not resolve an error about MSEXCHANGEIS performance counter (mdbperf.dll). I've read instructions for this and I've enabled the counter using exctrlst.exe. The error doesn't disappear even if I've restarted the service. Before to newly install exchange in repair mode (It's too dangerous !!!) I ask for help. My server is Exchange 2003 Std. SP2 (SBS 2003 Pre SP1) italian version. If I use perfmon.msc I can add all performance counters of MSEXCHANGEIS ! ...

Visio 2007, Vista 64, VISIO.EXE 32 stays loaded, 100% CPU
Whenever I run Visio 2007 under Vista 64, it starts a process, VISIO.EXE 32 which takes about 50% of the CPU. Sometimes it starts two copies and then it takes 100%. I used this visio under XP and it did not do this. I have all the MS patches in as well as everything from Lenovo for the Thinkpad. It is running Core 2 Duo with 3 Gig of ram. ...

Can't delete a particular public folder
I have a public folder (now named "Bad Folder") on my Exchange 2003 server that I can't delete. When I try to delete it, while I am logged in as "admin" on the Windows 2003 Server that the Exchange 2003 Server runs on, I get prompted for my username and password. No matter what I enter I just get re-prompted several times, followed by "The operation failed. ID 80004005. Exchange System Manager". I have check, re-checked, and changed the permissions (both "Client Permissions" and "Administrative Rights") from "anyone can do anyth...

Unable to display the folder error.
I get the following message when using Outlook. If I close Outlook then reopen it, it will work until I switch icons (calendar to contacts). "Unable to display the folder. Microsoft Outlook could not access the specified folder location. An error occurred that prevented the file M:\Outlook\cij.pst from being saved. Close and then restart all mail-enabled applications." Can anyone help me with this problem? ...

Missing Folders.
I get the following error when trying to start Outlook, I checked and verified the specified file contains no data. What are my options here? Unable to display the folder. Microsoft Outlook could not access the specified folder location. The file C:\Documents and Settings\Shawn Speelman\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst is not a personal folders file. -- I ran the inbox repair tool on the missing file and got the following message: "This file cannot be reocvered because it is not large enough to contain any useful data." Shawn Speelman <...

Cannot Delete A Public Folder
Folks, For some reason I have run into a weird problem on a folder within our Public Folders. This folder is no longer in use and must be deleted, however, when I right click it in Outlook the option to delete is greyed out. The properties page is also screwed up because I cannot add users or permissions to it. I believe the root of my problem is because the one and only defined user for this particular left the company and his AD account was deleted. All I see as a permitted user/author is the SID string of numbers. Is there a way to delete this folder manually? I've look...

Public Folder Migration #4
Adding a BE Exchange server to our topology. Have migrated all mailboxes to new BE server, and am trying to migrate public folders from what will be the FE server to the BE server. Using the PFMIGRATE script, here are the results: PFMIGRATE.WSF /S:SOURCESERVER /T:TARGETSERVER /A /N:ALL /SC Microsoft Exchange Public Folder Migration Tool Wed Jun 28 08:06:29 MDT 2006 Source Server: NAMESOURCE Version 6.5 (Build 7638.2: Service Pack 2) Target Server: NAMETARGET Version 6.5 (Build 7638.2: Service Pack 2) WMI Server: NAMETARGET Add Replica Mode in progress. Analysis of 1 folders with repl...

ESM
Hi, I created some Public folders in OL 2003 before Xmas no problems as I am the administrator for the local domains server & Exchange admin. Today I tried to create additonal folders form my LAN XP machine but continually receive the error of: Unable to create the folder. You do not have sufficient permission to perform this operation on this object. See the folder contact or your system administrator. When I look at the folder properties in OL I see the folder contact is NT USER:S-1-5-21-606747145-1682526488-682003330-1109 but I have no idea who that is...or was more likely! If I then g...

How to add another user's Contacts folder to my Address Book?
Background: Exchange 2003 Server w/ Outlook 2000/2003 clients. I can add any Contacts folders in my mailbox to my Address Book by going into the Properties of the folder and checking "Show this folder as an e-mail Address Book" on the "Outlook Address Book" tab. However, if I have another user's mailbox (to which I have full permission) in my Folder List, I do not have this option in any of their Contacts folders. How do I add another user's Contacts folder, displayed in my Folder List, to my Address Book? TIA, roshan After a bit of research on SlipStick.com...

Undeleting a folder in Express
Can anyone direct me to a free software download that will allow me to undelete a folder in Outlook Express or am I stuck purchasing the required software? This newsgroup is for support of Outlook 97, 98, 2000 & 2002 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x http://support.microsoft.com/newsgroups/default.aspx?ICP=GSS3&NewsGroup=microsoft.public.windows.inetexplorer.ie5.outlookexpress&a...

Formula involving different sheets
Hi Using Excel 2003. In sheet 1, cell A1: =200/1200 In sheet 2, cell B2: =300/1200 In sheet 3 in a cell, I want to do =200/1200 + 300/1200 by cell reference. How do I do so? Thanks. Your formula would be: =sheet1!a1+sheet2!b2 The best way to create these formulae is to get Excel to do it. 1: Type = into your cell 2: Navigate to your sheet1!a1 cell. You will notice in the formula bar that Excel is adding its address to your formula 3: Type + 4: Navigate to your sheet2!b2 cell. 5: Hit enter Once you learn this, you will never type a cell address again. Regar...

Passing data to DLL problem
Hi, my application uses a callback function in a dll. This function must notify the main application when it is called, through a SendMessage api call. So i've created a global variable in the dll, named parent: HWND parent; LRESULT CALLBACK MyFunction(...........) { ......................... SendMessage(parent, ....................); } in the main application i set the dll variable: HWND * wnd; wnd = (HWND *) GetProcAddress(hinstDLL, "parent"); *wnd = hWnd; this works fine if i use the parent variable it in a normal dll function, but in the callback MyFunction parent resu...

Junk E-mail folder
Is it possible to configure the Junk E-mail folder to automatically and permanently delete items older than 30 days? Thanks. You can use the AutoArchiving to do that. Right click on the folder, choose Properties and go to the AutoArchive tab "Jaycee" <jaycee131973@hotmail.com> wrote in message news:%232IGo%238NGHA.2300@TK2MSFTNGP15.phx.gbl... > Is it possible to configure the Junk E-mail folder to automatically and > permanently delete items older than 30 days? ...

MFC in DLL
I want to add MFC objects (CString) to DLL project. I added: #include <Afx.h> to stdafx.h file. I get the message "fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>". I tried to add: #undef _WINDOWS_ before #include <Afx.h> Than I had linking problems. I added: /FORCE:MULTIPLE to Linker->Command line DLL project was successfully compiled. This DLL is run successfully by snmp.exe But It throws exception, when I close it. I think, that my solution was incorrect. How do I solve this problem?!? "Max V...

Launch folder windows in separate processe
The setting as in subject selected under Control Panel -> Folder Options More than one windows explorer open. Each of them opened in other folder. One of them opened for search function. However, if investigating with Task Manager all windows explorer windows lead to the same explorer process (task right click -> Go to process). The list "Processes" of task manager presents only one explorer window. So the setting as mentioned above not really functional. What's the reason? kakii wrote: > > The setting as in subject selected under Control Panel ...

Disabling Microsoft Money Background Banking Service (mnybbsvc.exe) in 2007
I found the instructions for 2008, which is a simple check box in the settings, but is there any way to disable it in earlier versions? In microsoft.public.money, Milhouse Van Houten wrote: >I found the instructions for 2008, which is a simple check box in the >settings, but is there any way to disable it in earlier versions? You could remove your LiveID. ...

Help: MAPI can't find PSTPRX.DLL
Hi there Can anyone suggest how I can make outlook 2002 work properly. Everytime I press send/receive it says MAPI can not locate PSTPRX.DLL. I have done search and it is not on my computer. Please can anyone assist? just trying out 1st time >-----Original Message----- >Hi there > >Can anyone suggest how I can make outlook 2002 work >properly. Everytime I press send/receive it says MAPI can >not locate PSTPRX.DLL. I have done search and it is not >on my computer. Please can anyone assist? >. > See if this info helps: http://support.microsoft.com/default.asp...

ESM error stating that mapi32.dll is the wrong version
Hi, Problem solving a failed Exhange 2000 SP3 server, I had to install IIS and Reinstall Exchange. Copied back ofline backup and all seemed Okay. Nagging problem. Everytime I start ESM, I get a message that mapi32.dll is the wrong version. (Note: it is the Exchange sp3 version....) I have done a bit (lot) of reading on this and it tends to relate to putting Outlook on the same machine. Office\Outlook is not installed (not sure but doubt it ever has). All stated fixes are for restoring the Outlook version (mapifix.exe). I want to get ESm working. Note; ESM continues to load if o...

Cannot find DLL when starting debugging
Sorry for asking this here, but vstudio.general seems to be rather sleepy... Anyway: I have an MFC app which utilizes a 3rd party DLL which is located in its own place on the harddrive. I've tried to put the path to the directory where the DLL can be found in the list under 'Tools', 'Options', 'VC++ Directories', 'Executable Files', but it still can't seem to find the DLL when I try to debug my app. I know I could just copy the DLL to my Debug directory, but ahh that's really clumsy. Isn't there an other way ? :-| Bendik "Bendik E...

Q: How different colum-widths?
Hello NG, i am working on a word document, wich contains some excel sheets as inserted objects. now i want to merge some of these excelsheets. unfortunately they have different coloum- widths. is it possible to merge them and say to ecxel, that from here and further down to use different coloum- widths, then in the upper part of the sheet? thanx, Tom. -- _______________________ http://tom.lautenbacher.biz _______________________ Excel doesn't support different columnwidths per row. You might be able simulate it by merging cells together (format|cells|alignment tab). But merging ...

orphan personal folders file
I've got a personal folders entry on my outlook 2003 folder list that isn't connected to any actual folders. If I click on it I see an error message that says "The set of folders could not be opened" Presumably somewhere in the registry is an entry that leads to a null or non-existant file. Could anyone point me at a remedy? I've searched MS Support but no help there. Thanks Posted here countless times. You have a corrupt profile, probably from migrating a data file incorrectly. It's harmless. If you want to fix it, create a new profile from scratch. --...

Sharing folders between User Accounts on same PC
Non of my data is stored on C: but on another partition on the drive. I have several User Accounts for different hobbies, etc. I want to share a folder so it is viweable on the desktops of the User Accounts, but I don't want to move the folder onto C: - I want it to stay in it's location. Is this possible? TIA. "Richard" <noggod@ntlworld.com> wrote in message news:eadR9R0HLHA.1868@TK2MSFTNGP05.phx.gbl... > Non of my data is stored on C: but on another partition on the drive. > > I have several User Accounts for different hobbies, etc. &...

Toolbar of different sizes of button
Hi All, I am trying to create a toolbar for IE using ATL+MFC. I want to create a toolbar just like google but without any combobox etc. simple buttons but I have to have different size of buttons on the toolbar. like the first button would be more in width the second and thrid one would be smaller. I tried using SetBitmapSize(); SetButtonSize(); for this but it doesnt seem working.(I am not using imagelist at the moment) if it is better to use imagelist in this situation? more over I put a button image extracting it from MSN toolbar it was a bitmap with pink back ground when I used it as im...

Exch 5.5 public folder duplication
We have created a Public folder of type Post. All users can post and read from it. We use it as an items for sale area. Sometimes, however, multiple entries of the same entry appear, sometimes 2, 3 or 4 copies. Anyone know what might be causing this? ...