Getting path and Hwnd of application

1. How can I get the path of the application?
I used FILE* fp = fopen("log.txt", "wt"); to create a log file.
But the file is located in the folder in which I opened a file using
CFileDialog.
I would like the log to be in the same folder as the app.
I think a better way to do is to reset the folder setting (is there such a
thing?) after CFileDialog so that ".\" is the folder of the application.

2. I'm writing a dll that is called by some third party app, how could I get
the app's HWND?
I'm not using MFC.

Thanks.


0
someone913 (592)
11/17/2004 9:39:54 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
554 Views

Similar Articles

[PageSpeed] 5

Leesei wrote:
> 1. How can I get the path of the application?
> I used FILE* fp = fopen("log.txt", "wt"); to create a log file.
> But the file is located in the folder in which I opened a file using
> CFileDialog.
> I would like the log to be in the same folder as the app.

GetModuleFileName( NULL, [...] );

> 2. I'm writing a dll that is called by some third party app, how could I get
> the app's HWND?

The best possible way is to provide HWND as parameter of a function (if 
you have the control over the dll api).

You could enumerate windows in search for suitable candidate. A good 
candidate is the window that belongs to the same thread (or at least the 
same process), has focus, is visible, is highly z-ordered. Maybe there's 
some algorithm on the Net?

0
mac1 (347)
11/17/2004 10:21:30 AM
Thanks.
Then just forget about the HWND thingy. I can do without it anyway.

As a followup for the first question, I'm writing a MFC app (wrapper) that
calls a console program.
That console program use fopen("abc.txt", "rt")  to test if the file
"abc.txt" exists.
I'll do different thing accoeding to the content of "abc.txt".
My thought is that if I put the wrapper, the console program and the abc.txt
in a same folder, the console can detect the text file.
But as I mentioned before, the working folder of the console program is the
folder which CFileDialog  last used. How can I set the working folder of the
console program?


"Mihajlo Cvetanovic" <mac@RnEeMtOsVeEt.co.yu> wrote in message
news:419B262A.10601@RnEeMtOsVeEt.co.yu...
> Leesei wrote:
> > 1. How can I get the path of the application?
> > I used FILE* fp = fopen("log.txt", "wt"); to create a log file.
> > But the file is located in the folder in which I opened a file using
> > CFileDialog.
> > I would like the log to be in the same folder as the app.
>
> GetModuleFileName( NULL, [...] );
>


0
someone913 (592)
11/18/2004 7:41:52 AM
Leesei wrote:
> As a followup for the first question, I'm writing a MFC app (wrapper) that
> calls a console program.
> That console program use fopen("abc.txt", "rt")  to test if the file
> "abc.txt" exists.
> I'll do different thing accoeding to the content of "abc.txt".
> My thought is that if I put the wrapper, the console program and the abc.txt
> in a same folder, the console can detect the text file.

There's another solution, pass the full path name of abc.txt to console 
program as command line parameter.

> But as I mentioned before, the working folder of the console program is the
> folder which CFileDialog  last used. How can I set the working folder of the
> console program?

SetCurrentDirectory, but I wouldn't use it if I don't have to. All sorts 
of unexpected things may show up in worst possible moments.

0
mac1 (347)
11/18/2004 9:16:03 AM
SetCurrentDirectory works for me.
Thanks.

"Mihajlo Cvetanovic" <mac@RnEeMtOsVeEt.co.yu> wrote in message
news:419C6853.1030405@RnEeMtOsVeEt.co.yu...
> Leesei wrote:
> > As a followup for the first question, I'm writing a MFC app (wrapper)
that
> > calls a console program.
> > That console program use fopen("abc.txt", "rt")  to test if the file
> > "abc.txt" exists.
> > I'll do different thing accoeding to the content of "abc.txt".
> > My thought is that if I put the wrapper, the console program and the
abc.txt
> > in a same folder, the console can detect the text file.
>
> There's another solution, pass the full path name of abc.txt to console
> program as command line parameter.
>
> > But as I mentioned before, the working folder of the console program is
the
> > folder which CFileDialog  last used. How can I set the working folder of
the
> > console program?
>
> SetCurrentDirectory, but I wouldn't use it if I don't have to. All sorts
> of unexpected things may show up in worst possible moments.
>


0
someone913 (592)
11/19/2004 2:04:14 AM
Reply:

Similar Artilces:

How can I get my forgotten password
I have protected my sheet in Exceel, which I forgotten my password. Would you please let me know how can I recover it? try searching password sub mcgimpsey probably won't make any difference if you do a web or a groups search. --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "Golam Rahman" <Golam Rahman@discussions.microsoft.com> wrote in message news:47998858-7F28-4CEE-A061-E0A24B5B09AD@microsoft.com... > I...

How Big can Company Data Bases get
Company running Dynamics GP Standard 1) How big can we allow their database to get? I beleive it is approaching the limit, so I would like to go through and eliminate old data. But first as their year end approaches, I would like to copy the existing data to a second data base- (a back company up per say so they could easily enter that company and then go back in time that way). Would someone have detailed instructions on how to do this? -- Clay Tait How big is it now and what makes you think it's near "the limit"? The limit tends to be pretty fluid depending on hardwar...

Right Margin gets cut off when printing a tri-fold brochure
Why is it that when I attempt to print a tri-fold brochure on my HP Deskjet 1220c, all the preset margins on the brochure template print just fine except the right margin. The right margin is invariably cut off and is approx. .5" instead of the preset margin of .25"? What are your printer's limitation? Open WordPad, file, page setup, input zero into the margin settings, WordPad will default to your printer's margin limitation. You will have to adjust your brochure accordingly. -- Mary Sauer MS MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.mic...

How do I get the formula icon back on my toolbar?
I seem to have lost the formula icon off my toolbar and don't know how to get it back so that I can do quick sums in my spreadsheet. How do I do this please? hi are you talking about the autosum icon. if so then.... right click any toolbar and from the popup. click customize. in the customize dialog, click the commands tab. on the left, click insert. on the right, scroll down to autosum right click and hold the autosum icon and drag it to where ever you want it. release the mouse. close the customize dialog. done. regards FSt1 "Andrea confused" wrote: &...

How to get the PivotTable report info that feeds another PivotTable report.
A pivot table can get it's data from another pivot table as so: Right click in the pivot table and select PivotTable Wizard Click the < Back button Click the next < Back button Select the "Another PivotTable report or PivotChart report" radio button and click Next > Select the pivot table containing the same data and click Finish What I want to get is the source pivot table for a pivot table. I guess I'm looking for the "parent" of the "child" pivot table :-) How can I do this in VBA? Here's the macro recording of the above steps but it di...

Getting space between text and right border. " " not working.
I have a =NOW() cell formatted as: yyyy.mm.dd.ddd., hh"h"mm but even when I make it: yyyy.mm.dd.ddd., hh"h"mm" " I don't get any more space between the end of the time and the right-hand border and it's printing too close to the edge. What is the fix for this one, pls? Thank you! :oD Try turning wraptext off. It seemed to make a difference in xl2003. StargateFanFromWork wrote: > > I have a =NOW() cell formatted as: > > yyyy.mm.dd.ddd., hh"h"mm > > but even when I make it: > > yyyy.mm.dd.ddd., hh"h&q...

Bought Money 2006, reinstalled computer, now idea how to get it ba
I paid for a copy of Money 2006 Premium. I reinstalled my machine recently and found a link to download the trial version of MS Money, which I did, thinking there was a way to reactivate my product, but if there is, I can't find it. How do I get my paid for version back? I still have my receipt and can log into the billing support site. Thanks. Open the sample file. Assign it the Passport you used to buy the copy. Do an Internet Update. Open your own data file. Next time buy the CD. "Architekt" <Architekt@discussions.microsoft.com> wrote in message news:3137CC7D-6B7...

UNC Path length problem opening a file in excel 2002 or 2003
I've had several of my users that can't open an excel file when the UNC path length gets close to 220 characters. The UNC points to a 2003 server. This happens if you try to open using windows explorer or using the OPEN command in excel. Only excel is giving us problems. Word and other programs work just fine. I can't find anything in the knowledge base. Has anyone else seen this problem? Thanks John P.S. Please CC to j w a r r e n _ r e m o v e (a t ) p r u d e n t r x _ r e m o v e . c o m Take out the "_ r e m o v e" from the address. From Excel Help ...

get rid of extra rows
I have this nice spreadsheet, but somehow additional rows were created at the bottom, and I can't get rid of them by "deleting", backspace, editing and deleting the formatting in those rows. Suggestions? You can't change the number of rows in an XL sheet (65536 pre-XL07, over a million in XL07). You could hide them instead (Format/Row/Hide). In article <761C1720-3B35-4FBC-8C58-A48AE057C8D4@microsoft.com>, kendallzemp <kendallzemp@discussions.microsoft.com> wrote: > I have this nice spreadsheet, but somehow additional rows were created at the > bot...

Get an error when opening Public Folders
When trying to open public folders in Exchange System manager. the token supplied to the function is invalid. id no. 80090308. Do I need a MAPI client on the server like Outlook? I always thought it was a big no no to put Outlook on the same box as Exchange is installed. Thanks On Sun, 27 Mar 2005 16:35:02 -0800, "John McCoy" <JohnMcCoy@discussions.microsoft.com> wrote: >When trying to open public folders in Exchange System manager. the token >supplied to the function is invalid. id no. 80090308. http://support.microsoft.com/?id=324345 > >Do I need a MAPI cl...

Upgading Office -- will I get VPC 7?
Hello all- I currently have Office v.X for the Mac; I don't have Virtual PC. I was planning to get VPC 7 w/Windows XP. However, I notice that for only $60 more I can get Office 2004 for Mac Professional Upgrade, which include VPC 7. If I buy this upgrade, will I be able to use VPC 7 even if I don't already have an earlier version of VPC? Thanks in advance, jf In article <1129607198.334577.174130@f14g2000cwb.googlegroups.com>, google@jfruh.com wrote: > Hello all- > > I currently have Office v.X for the Mac; I don't have Virtual PC. I was > planning to get ...

How do I get invisible lines & borders to re-appear?
In Publisher 2003, table grid lines, text box borders and autoshape borders have become invisible on-screen, although they do print out. Any ideas on how to remedy this? Recently installed Adobe PDF Maker which seems to have precipitated this, although it could be entirely co-incidental. Try updating your video drivers. -- JoAnn Paules MVP Microsoft [Publisher] "Ackerman & Co" <Ackerman & Co@discussions.microsoft.com> wrote in message news:0FFE40C2-D6A8-43AE-89E4-061EBB6501DB@microsoft.com... > In Publisher 2003, table grid lines, text box borders and auto...

How do I copy a graph to new worksheet and get data from new sheet?
When I copy a worksheet with a graph or just copy a graph and paste in a new worksheet, the source data is still linked to the original worksheet. I've tried editing the sorce data to remove the sheet name to try to make it relative to the current sheet, but that gives me "Error in your formula". Is there a quick way to get the graph to link to the data in the new worksheet? Even a macro would help, if that's what it takes. Thanx in advance... If the chart is embedded in the worksheet, you should be able to copy the worksheet elsewhere, and the copied chart will point t...

ShellExcute and System Path
I have Windows XP and Windows Vista PC's. I need to use ShellExcute in my MFC application and run the dos ping command with a hidden window. Can some gentleman here give the right syntax? Regards Ronny maybe IcmpSendEcho IcmpSendEcho2 IcmpSendEcho2Ex can help you. a sample from MSDN: #include <winsock2.h> #include <iphlpapi.h> #include <icmpapi.h> #include <stdio.h> #pragma comment(lib, "Iphlpapi.lib") #pragma comment(lib, "Ws2_32.lib") int __cdecl main(int argc, char **argv) { // Declare and initialize variables HANDLE hIcmpFi...

Getting grip on dependents
Hi, In my spreadsheet ther is a field that has a dependent in an other worksheet. How can I find that. the VB property 'dependents' will only return dependents on the same worksheet. best rgds, Ton Ton, It's a nasty one. A small extract of a much much bigger routine kludged quickly purely to demonstrate how to test it. Might be bugs in this, since I haven't tried doing anything with it. 'you would probably set up some kind of loop here but for the time being Set rngTestCell = cells(1,1) 'use the showdependents method then try and navigate along the arrows rng...

Application.wait
Can anyone tell me what library reference I have to install to use application.wait in my VBA in access 97 ? Thanks Jon There is no Wait method for the Application object in Access. What are you trying to do? You might be able to use the Sleep API (see http://www.mvps.org/access/api/api0021.htm at "The Access Web" for an example), or, if you're trying to wait until a shelled process is finished, see http://www.mvps.org/access/api/api0004.htm -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "jon" <jon@dontemailme.c...

User not Getting Some External E-mail but Message Tracking says He Is
Exchange 2000 SP4, Outlook XP. External email from a particular person apparently does not get delivered to one user's Exchange mailbox even though Message Tracking shows that it has. Another user gets the same external email in his mailbox OK. I have asked the user who isn't getting mail to check to see if he hasn't created a rule to move mail from this person to another folder. Any other ideas would be gratefully appreciated. Sorry! Should have posted in Exchange 2000! "Bill Glidden" <billyg1943@hotmail.com> wrote in message news:OB2PIpDMGHA.500@TK2...

My application does not register itself to windows file manager
Hi, I have an application , it does not register itself to windows file manager ( I mean , if I double click on a document of my application type, it does not open) How can I make it register itself, Thanks, CWinApp::RegisterShellFileTypes() is the answer. You would also need to call EnableShellOpen before calling RegisterShellFileTypes(). Check MSDN for more details: http://msdn2.microsoft.com/en-us/library/538tbk4a(VS.80).aspx Regards, Shoaib. "behzad" <bn at yahoo.com> wrote in message news:%23F4AZmgnIHA.5472@TK2MSFTNGP03.phx.gbl... > Hi, > I have an applic...

Getting rid of blank rows withouth deleting them #2
I wanted to find a way to make it automatically because i have to do i in many worksheets, but this works great, Thanks a lot for the hel -- sams ----------------------------------------------------------------------- samsg's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1624 View this thread: http://www.excelforum.com/showthread.php?threadid=27725 ...

Re: New Website and getting indexed Found out that prince harry seems to be in thenews
http://pearlcompany.ca/labels/prince%20harry%20girlfriend.html seems to be really popular in google these days but with all the bragging I see on google adsense I still have yet to have one successful steady income of checks why do you guys always lie how easy it is and I haven't even got one click yet how am I suppose to get to 10 bucks to even get verified? I would rather get a steady check every two weeks I just don't get it what does it take? ...

path for saving files on Desktop?
Apologies for a dumb question, but I am not familiar with the Windows platform: How can I get the path for saving a file on the Desktop or Documents folder of the current XP user? Thanks! Andrew Hi, You can use SHGetSpecialFolderLocation function with CSIDL_DESKTOP & CSIDL_PERSONAL for desktop and document path respectively. Check http://kiranu.wordpress.com/2006/07/27/getting-special-folders-path/ for example code. /Kiran abrtlt@yahoo.com wrote: > Apologies for a dumb question, but I am not familiar with the Windows > platform: > How can I get the path for saving a file on...

I cannot get my sheet to fit the page
I have followed all formatting suggestions but in printing landscape, onto an 8.5 x 11" page, my worksheet still doesn't fit the entire page and is too small to read, the spaces aren't adequate enough. I have tried adjusting row height, and if I choose the scaling option then the end of my columns spill onto another page....help! I use excel 2003 and if the sheet will not fit the page, is to small to see print, then how else would you make it fit on one page but to make it even smaller. What are you actually asking for. The adjustments that have available are -- margins...

excel function to get tab name
On the first tab in my worksheet, I have several cells in a colum in which the cell reference returns the value of cell A1 from the subsequent tabs. For example, the workbook has 10 tabs named Tab1, Tab2...Tab10, and in Tab1, the formula in cell A2 is "=Tab2!A1", and the formula in cell A3 is "=Tab3!A1"....cell A10 is "Tab10!A1". Sometimes, I will add and delete these subsequent tabs (Tab2 through Tab10) and then have to manually re-link the references to A1 on each of these tabs back to the column on Tab1. Is there some way to do this with a relative r...

check if programme exist with HWND
Hello NG, so I have a HWND of an application. Sometime it crashes, and so my CopyData runs into unknown space. Is there a possibility to find otu, if an HWND is still alive or if the programme has crashed or was stopped in another way? (I can't find it in Task Manager then). Thanx for help Guido Guido Franzke wrote: > Hello NG, > > so I have a HWND of an application. Sometime it crashes, and so my CopyData > runs into unknown space. > Is there a possibility to find otu, if an HWND is still alive or if the > programme has crashed or was stopped in another way? (I can&...

External Application
Hi All, Can anyone tell me how to write into an applicationt that will only work on a flash drive (removable) or a mapped drive rather than a physical drive? Many thanks in advanced Not to worry - resolved now "Crouchie1998" wrote: > Hi All, > > Can anyone tell me how to write into an applicationt that will only work on > a flash drive (removable) or a mapped drive rather than a physical drive? > > Many thanks in advanced ...