Can dll find path where it's running from

hi, I made a mfc-using dll, can I have it programatically find itself
so it knows where on the hard drive it is being run from?

This is In order to find itself to load its manifest because I want to
have it programatically load its own manifest instead of using
resource id 2.

Or even better...

In the documentation of the CreateActCtx function,

http://msdn2.microsoft.com/en-us/library/aa375125(VS.85).aspx

there is a reference to ACTCTX_FLAG_MANIFESTSTREAM_REQUEST flag, and
the ManifestStream member of ACTCTX however neither exist in my Visual
Studio. Do these really exist?
0
1/21/2008 10:09:24 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
601 Views

Similar Articles

[PageSpeed] 59

"alexl" <alextheblade@gmail.com> wrote in message 
news:fa024c3a-bda2-4d45-9e40-71c16984ff81@p69g2000hsa.googlegroups.com...
> hi, I made a mfc-using dll, can I have it programatically find itself
> so it knows where on the hard drive it is being run from?
>
> This is In order to find itself to load its manifest because I want to
> have it programatically load its own manifest instead of using
> resource id 2.
>

Use GetModuleFileName().


> Or even better...
>
> In the documentation of the CreateActCtx function,
>
> http://msdn2.microsoft.com/en-us/library/aa375125(VS.85).aspx
>
> there is a reference to ACTCTX_FLAG_MANIFESTSTREAM_REQUEST flag, and
> the ManifestStream member of ACTCTX however neither exist in my Visual
> Studio. Do these really exist?

Make sure you have the latest SDK.

-- David


0
dc2983 (3206)
1/21/2008 10:43:41 PM
If you need your main application to find it you can do something like the 
following code as well:

CString csModulePath;

// Get the full path for the DLL from the resource handle.  csFilename is 
just the filename of the DLL.
TCHAR *p;
SearchPath(NULL,csFilename,NULL,MAX_PATH,csModulePath.GetBuffer(MAX_PATH),&p);
csModulePath.ReleaseBuffer();

Tom

"alexl" <alextheblade@gmail.com> wrote in message 
news:fa024c3a-bda2-4d45-9e40-71c16984ff81@p69g2000hsa.googlegroups.com...
> hi, I made a mfc-using dll, can I have it programatically find itself
> so it knows where on the hard drive it is being run from?
>
> This is In order to find itself to load its manifest because I want to
> have it programatically load its own manifest instead of using
> resource id 2.
>
> Or even better...
>
> In the documentation of the CreateActCtx function,
>
> http://msdn2.microsoft.com/en-us/library/aa375125(VS.85).aspx
>
> there is a reference to ACTCTX_FLAG_MANIFESTSTREAM_REQUEST flag, and
> the ManifestStream member of ACTCTX however neither exist in my Visual
> Studio. Do these really exist? 

0
tom.nospam (3240)
1/22/2008 1:06:47 AM
thanks guys!
0
1/22/2008 3:32:49 AM
This won't quite do the job.  The reason is that this will use the search path, but the
DLL might not have been loaded by the search path; it might have been loaded via an
explicit LoadLibrary that gave a specific path.

GetModuleFileName will give the correct result, because it doesn't try to re-evaluate what
the search path might have been, but actually reveals the place it came from.  Also, in
side-by-side installs, it is problematic what SearchPath is actually going to reveal.

I use GetModuleFileName in my LoadLibrary Explorer.
					joe

On Mon, 21 Jan 2008 17:06:47 -0800, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>If you need your main application to find it you can do something like the 
>following code as well:
>
>CString csModulePath;
>
>// Get the full path for the DLL from the resource handle.  csFilename is 
>just the filename of the DLL.
>TCHAR *p;
>SearchPath(NULL,csFilename,NULL,MAX_PATH,csModulePath.GetBuffer(MAX_PATH),&p);
>csModulePath.ReleaseBuffer();
>
>Tom
>
>"alexl" <alextheblade@gmail.com> wrote in message 
>news:fa024c3a-bda2-4d45-9e40-71c16984ff81@p69g2000hsa.googlegroups.com...
>> hi, I made a mfc-using dll, can I have it programatically find itself
>> so it knows where on the hard drive it is being run from?
>>
>> This is In order to find itself to load its manifest because I want to
>> have it programatically load its own manifest instead of using
>> resource id 2.
>>
>> Or even better...
>>
>> In the documentation of the CreateActCtx function,
>>
>> http://msdn2.microsoft.com/en-us/library/aa375125(VS.85).aspx
>>
>> there is a reference to ACTCTX_FLAG_MANIFESTSTREAM_REQUEST flag, and
>> the ManifestStream member of ACTCTX however neither exist in my Visual
>> Studio. Do these really exist? 
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)
1/22/2008 10:33:04 PM
Good point.  It works for me since, in my programs, I rely on the search 
path to find the DLLs.  I use it before I load a DLL (like for translated 
languages, etc.) to make sure the version is correct for the EXE.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:dlrcp3d93iur9jobv7bnnm33k2n6tlst3o@4ax.com...
> This won't quite do the job.  The reason is that this will use the search 
> path, but the
> DLL might not have been loaded by the search path; it might have been 
> loaded via an
> explicit LoadLibrary that gave a specific path.
>
> GetModuleFileName will give the correct result, because it doesn't try to 
> re-evaluate what
> the search path might have been, but actually reveals the place it came 
> from.  Also, in
> side-by-side installs, it is problematic what SearchPath is actually going 
> to reveal.
>
> I use GetModuleFileName in my LoadLibrary Explorer.
> joe

0
tom.nospam (3240)
1/22/2008 11:05:53 PM
Reply:

Similar Artilces:

System headed South.. What can I do?
2 days ago.. all Ok.. 1 day ago, see wierd behavior as I double click on a .xls worksheet or launch Excel in my Office 2002XP.. I get a dialogue box immediately asking me to Install a Windows XP PRO module that is on the CD-ROM.. I have Win XP HOME.. and still see thhis error after reboot/ virus scan and registry cleanup..does same thing under different login names.. This morning, i boot up see an error box and repeadedly must close the dialog box to get rid of hyroglyphic foriegn text, and upon closing last of 10 or so repeating error boxes, my cursor disappears completely.. rebo...

Why have to run rules manually to process emails
Hi, I am running outlook 2002 on a W2K box, with all up-to-date service packs. Although I keep my outlook running, it sometimes does not filter out emails when it should. And, if I manually run the rules (via rules wizard), the emails are processed as specified by the rules. Why is this? (I am aware that sometimes, when outlook starts up, it may not process some emails; but this is not the case since my outlook is kept running). Thanks. Yan ...

Outlook continues to run in the background after exiting program
Hello all, I am having a problem with Outlook XP on my home computer. I am running Windows XP Professional with Service Pack 1 and all security and critical updates installed on this machine. Recently, I have noticed that Outlook continues to check for e-mail or bring up event alerts even after I have exited the program using the Exit option in the File menu. When I bring up the Task Manager and check the running processes, I find OUTLOOK.EXE still running in the background. I then force the program to quit to stop Outlook from checking for new e-mails or bringing up event alert...

find serial number in RMS database
I have a problem and i want someone help me. A saler who use the POS operator create a new serial number (bad serial number which is not in the availabled serial number list) to sell a particular item. I look for a good table in the database to change the bad serial number with the good one. I thing find it in the table named serial. The surprise i have, the view of the product inventory show me the good serial number as what solde (in the POS MAnager), but when i try to review the tiket i saw the bad serial number. i'm not still see where the report find out his serial number. I ...

Do I need to run this process in separate thread?
I have a C# project with one form. A single button starts a process, and it runs for about five minutes, iterating through a number of tests. During that time, the form blanks out (turns gray) and, if I click on the form, the title box reads (Not responding). When the process is finished, it returns. On the form, I have placed a label, and the underlying code puts the value of the current iteration so I can watch its progress from 1-N iterations. However, as the form blanks out, I can't see the values increment. I suspect that I should run the process on a separate threa...

"Settings" and KB unavailable when Outlook is running (CRM 3.0)
Does anyone else find it rather ridiculous that the options available in the CRM 3.0 web client completely change when Outlook is running? Evidently this is "by design" but was a very poor design choice in my opinion. Users like to have a consistent experience, and when options start disappearing it confuses people. It also makes it very difficult to build a Knowledge Base and set up users, considering most people will probably be copying and pasting text from email messages to build the KB. The way it's set up now, you would have to find the email message you want, co...

Can I Customize Outlook 2003 Map Link?
In the Outlook 2003 contact form, the "map link" button attempts to display the location of the contact based on the address information. This feature used to work well, but lately it is extremely slow and often doesn't produce results. I would prefer to use Google Maps. Is there a registry entry I can use to accomplish this? The page http://www.outlook-tips.net/howto/displaymap.htm describes how to do this for earlier Outlook versions but this appears to break Outlook 2003. Do I have a workable option? AFAIK, you cannot customize it. it's reportedly broken for older v...

Project invoices can be deleted
When I create a billing entry in project, it automatically assigns it the next transaction number. I'll save it to a batch so that I can preview/print the individual invoice. If I Delete the invoice (after it has been saved), rather than post it, I cannot find a record of it anywhere. Further, the next invoice created will use the next sequential number, leaving a gap in the invoice numbers. I find this to be a poor control issue. GP should replace the Delete button with a Void button, thus leaving a nice audit trail and no missing invoices. ---------------- This post is a sugg...

can't download my msn hotmail on outlook express
Hi Iam a user of MSxp and want to know why Outlook express doesn't let me get my hotmail e-mail, it just stays checking for new messages from hotmail and that's it for the rest of the night. 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.publi...

How can I put a slash in a zero in Office 97
How can I put a slash in a zero in Office 97 Find a font that supports slashed 0's. Google will help you find lots--some will be free, others not. I found this a long time ago: http://www.qsl.net/wa6axe/fonts.html rmpete wrote: > > How can I put a slash in a zero in Office 97 -- Dave Peterson Thanks, Dave, I found two fonts I like, AnonymousTT and Monaco, with slashed zeros. I also found that you can add a slash to Arial with ALT+0216. Thanks again "Dave Peterson" wrote: > Find a font that supports slashed 0's. > > Google will help you find lots--so...

W2003: find cursor location in table coordinates (table/row/column
I've been asked to extract data from an existing form that I didn't set up, and the format is less than ideal. To minimize my cycles of testing, it would be much easier to place my cursor in a sample document, and then debug.print the cursor location as table coordinates so I can hardcode the 'cells' that I need to extract. There are about 15 tables total, and I'll have to extract content from most of them. I played around with the range.parent object but couldn't figure out how to return the table info. I also googled, but no joy. Any suggestions...

How can I attach a hyperlinked object in a workbook cell to email
I've very limited knowledge regarding programming in VBA, and would like to create a control button whereby hyperlinked objects within excel cells can be selected and sent as attachments to predetermined recipients for action automatically, and get a response back when that action has been completed. the idea being to have the same function would be available available on every row in the shhet of the workbook as required, such that the control button could be copied into each row as required. Any assistance would be greatly appreciated. ...

How can I find font?
I create a club monthly newsletter using Pub 2007. Its contents come from many sources--club members, websites, etc., etc. Occasionally when opening my monthly 'creation', I see the note that one of the fonts is 'not recognized' and I'm asked what font I want to substitute. I understand the theory behind this..... But--how can I find just where the 'unrecognized' font is used in my publication? I've gone through this issue lots of times and can't find it. (The font is "Times") Any pointers would be appreciated. Usually the font will be...

Outlook 2000 can't send mail over Exchange 5.0 if OS is XP Pro
Hi, maybe you guys heard about this problem and could give me a hint: Windows 2000 Server (SP3) with Exchange 5.0 (SP3) XP Pro (SP1) or Windows 2000 Pro with Outlook 2000 Clients. I can send mails from the Windows 2000 Pro clients, but with the "same" setup I can't on the XP Pro clients. I get two errormails back, which say that there is a network error. But the network is ok (can ping and get the server shares), I even can receive mails. I assume it is a authentication problem, but I don't know anymore where to look at. Please help. TIA Alex ...

Run report without running access?
Hi - Dumb question: To keep it simple, can I create a link or shortcut for a report so that with a click of the mouse the report will show? GWB wrote: > Hi - Dumb question: > To keep it simple, can I create a link or shortcut for a report so that > with a click of the mouse the report will show? You can have it open Access, then your file, then your report. But Access and your file have to be opened. ...

Run program with parameters
Outlook 2003/2007 I would like to run a new program when mail with a particular subject arrives, the catch is that I need the subject of the email to be a command line parameter. I'm able to setup a simple rule that runs an application when the message arrives, I just can't figure out how to get the subject of the email to be the command line parameter. Please help "BetaD" <dhorth@horth.com> wrote in message news:1157120133.417355.155080@b28g2000cwb.googlegroups.com... > Outlook 2003/2007 > I would like to run a new program when mail with a particular > s...

Mixed DLL Loading Problem.
Hi, Forgive me if this has been all hashed out somewhere. I am using Visual Studio 2003. I am using the book "Programming Microsoft DirectShow for Digital Video and Television". I have used Chapter 10 to learn enough to write a DirectShow Transform Filter COM DLL. That part worked OK. Then I wanted to add an IID_ interface. I needed a static variable in the DLL to hold a value that I want to pass in through the IID_ interface. That's when I discovered the linker error caused by MSIL whacko stuff apparently introduced in the first .NET compiler... :-) (LNK4210 &#...

how can i print postcard onto A5 with 2 copies to a page
how can i print postcard onto A5 with 2 copies to a page without any margin If your postcard is the standard 14.65cm x 11.05cm you can't. If you don't care if it is standard or not just divide your A5 stock in half, each card will be 14.8cm x 10.5cm -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "shree" <shree@discussions.microsoft.com> wrote in message news:4444CA0A-6BD2-4724-A512-6DE9744F1623@microsoft.com... > how can i print postcard onto A5 with 2 copies to a page without any margin Hi Mary, than...

Can't Generate Out-of-Office Response
Using SBS 2000 with Exchange 2000 and Outlook 2002, when we set Outlook to generate an Out of Office response, none is generated. How can I rectify this? Thanks! Larry -- Larry Lentz, MCSE+Internet & W2K, MCDBA GoldMine Certified Professional Lentz Computer Services www.LentzComputer.Net Larry@LentzComputer.Net ...

Can you archive just the inbox and not any sub-folders?
I'm using Outlook 2003 and when I select file>archive, I only see the option to "archive this folder and all subfolders". Is there a way to only archive the root folder and not the subfolders? If so, can this be done in Outlook 2002 also? Thank you. In news:1170421717.022349.228720@j27g2000cwj.googlegroups.com, pez <peter.zelonis@gmail.com> typed: > I'm using Outlook 2003 and when I select file>archive, I only see the > option to "archive this folder and all subfolders". Is there a way to > only archive the root folder and not the subfolde...

how can I convert pub95 to pub98
cn't get a file from pu95 to open in my version of pub98 Are you certain it is a 95 file? Some folks are receiving 2003 files and for some reason the properties are saying version 3.0. Send the file to me and I will convert it to 98. gsauer at columbus dot rr dot com -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Tom J" <Tom J@discussions.microsoft.com> wrote in message news:BDE8EBC2-3DFD-4EC8-B6E3-C1C45B9E20E8@microsoft.com... > cn't get a file from pu95 to open in my version of pub98 ...

can't resolve ActiveSync HTTP_500 error
We just added SP2 to Exchange Server 2003, and have also forced OWA clients to use SSL. Now ActiveSync 3.7 (from a WM2003SE phone) to the Exchange Server is failing, reporting error code HTTP_500 and "Synchronization failed because of a server error. Try again" on the phone. We got one event log entry on the server that pointed us to http://support.microsoft.com/?kbid=886346. Futzed around with that for a while, to no effect except that now we don't get any more event log errors... but the HTTP_500 is still foiling ActiveSync. Possibly related: the phone steps though the &...

Msimn, INETCOMM.DLL problem
Hi i hope someone can help me with this proble. Every time i try to send out a e-mail with Outlook express i get this "Msimn" fault i am not sure what to do, i tried re-installing outlook and getting the latest version it runs on Windows 98 and this is the message that i get in "details" of the error: MSIMN caused an invalid page fault in module INETCOMM.DLL at 0167:5ec1ee59. Registers: EAX=27c89c8c CS=0167 EIP=5ec1ee59 EFLGS=00010202 EBX=00000000 SS=016f ESP=0056d83c EBP=0056d8a8 ECX=00000000 DS=016f ESI=00000001 FS=631f EDX=0000000b ES=016f EDI=0056d8dc GS=0000 Bytes ...

urlmon.dll not compatible with Microsoft Oulook
I have installed Xp Pro SP2 and since then I get the following error when trying to open Microsoft Outlook 2003 (Microsoft Office 2003) urlmon.dll not compatible with Microsoft Outlook, reinstall Outlook I have reinstalled Microsoft Office 2003 and it doesn't fix the problem. All other Office products (excel, word, visio etc) work fine. Can you tell me where to get the correct version of urlmon.dll and where it should be located in windows. It is currenlty in windows/system32 .. but apparently it isn't the right version??? Thanks Dee <Dee@discussions.microsoft.com> w...

Call functions in parent from a runtime loaded DLL
Hello, I am developing a 'plugin' for a MFC-based GUI. The plugin is also MFC-based, and is a simple dialog. The plugin is loaded at runtime -- i.e. the DLL is not linked and no .DEF file is used. The user specifies the location of a plugin. The plugin needs to call function(s) in the main application. Can this be done? I can pass a pointer to the main application to the DLL. However, how do I tell the linker that calls like: parent->CallFromDll are not undefined but will be available at runtime? Thanks <egrayver@yahoo.com> wrote in message news:1156471416.335243.1...