Article View: borland.public.cppbuilder.nativeapi
Article #144Re: CreateProcessAsUserW and quoted path names...
From: Ed Mulroy [TeamB]
Date: Sun, 15 Jun 2008 20:12
Date: Sun, 15 Jun 2008 20:12
62 lines
3397 bytes
3397 bytes
> ...
> WideString wzAppName = (WideString)("\"" +
> Utils->getControlCentreExePath() + "\"");
> ...
> If I remove the double-quotes, the code works, but ...
Just a SWAG but might you have quoted twice?
""PathAndFileName""
instead of
"PathAndFileName"
. Ed
> Mike Collins wrote in message
> news:4855474a@newsgroups.borland.com...
>
> Hi all, I've got a problem that's just appeared today. Software system
> has been working fine for the last month so I assume MS have updated
> something.
>
> I have a service that runs and monitors certain aspect of the users
> computer. We have a system tray application that is used to relay
> information to and from the users desktop via an IPC conduit (since the
> system needs to work in vista and XP, and vista isolates services into
> session 0).
>
> When the user double-clicks on the system tray app, an IPC message is sent
> to the service, which in turn launches a configuration application on the
> users desktop. The code does this in the following stages:
>
> 1) WTSGetActiveConsoleSessionId();
> 2) WTSQueryUserToken();
> 3) DuplicateTokenEx();
> 4) CreateEnvironBlock();
> 5) CreateProcessAsUserW();
>
> - until today, this code was working fine. However, CreateProcessAsUser
> has started to return an error code, 123, The filename, directory name, or
> volume label syntax is incorrect. The second parameter
> (lpApplicationName) to this call is created thus:
>
> WideString wzAppName = (WideString)("\"" +
> Utils->getControlCentreExePath() + "\"");
>
> In the MSDN documentation, it states:
>
> "If you are using a long file name that contains a space, use quoted
> strings to indicate where the file name ends and the arguments begin;
> otherwise, the file name is ambiguous. For example, consider the string
> "c:\program files\sub dir\program name". This string can be interpreted in
> a number of ways."
>
> So to avoid the possibility of rouge program trying to imitate our config
> application, I use quotes around the path. This seems to be causing the
> problem. If I remove the double-quotes, the code works, but there is the
> potential of another application being placed in the root directory (with
> the same name) and being launched instead of ours.
>
> Can anyone help me out there. Does anyone know a work around or have any
> suggestions?
Technical Details
Message-ID:
<485577a5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4855474a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a169c88c9ed98680 X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <4855474a@newsgroups.borland.com> Subject: Re: CreateProcessAsUserW and quoted path names... Date: Sun, 15 Jun 2008 16:12:21 -0400 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 NNTP-Posting-Host: 69.142.0.27 Message-ID: <485577a5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1213560741 69.142.0.27 (15 Jun 2008 13:12:21 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail