🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6637

Re: Retrieving the Start from directory

#6637
From: Remy Lebeau (TeamB)
Date: Wed, 20 Apr 2005 22:38
20 lines
1857 bytes
"Marc" <bukwheat_NS@axess.com> wrote in message
news:4266c896$1@newsgroups.borland.com...

> If I have a batch file on my desktop I want my application
> to return the location of my desktop.

You will only be able to do that if the application resides on the desktop
as well to begin with.  There is no way to get the path of the process that
loads another process.  In this case, the EXE has no concept of the BAT
file, let alone the path the BAT is running from.

Well, I won't say "no way".  You can use WMI, but the code is quite ugly.
You can also use the Toolhelp API, but then you have to walk through all
running process IDs one at a time.  Plus, the Toolhelp API is not available
on NT4, if you need to support that platform.  Alternatively, you can use
NtQueryInformationProcess(), which is only available on W2K or higher.


Gambit
Technical Details
Message-ID: <4266d972@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4266bf60@newsgroups.borland.com> <4266c43b@newsgroups.borland.com> <4266c896$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d14a13f082d61e40
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4266bf60@newsgroups.borland.com> <4266c43b@newsgroups.borland.com> <4266c896$1@newsgroups.borland.com>
Subject: Re: Retrieving the Start from directory
Date: Wed, 20 Apr 2005 15:38:13 -0700
Lines: 22
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4266d972@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1114036594 68.69.17.41 (20 Apr 2005 15:36:34 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail