Article View: borland.public.cppbuilder.nativeapi
Article #142CreateProcessAsUserW and quoted path names...
From: Mike Collins
Date: Sun, 15 Jun 2008 17:57
Date: Sun, 15 Jun 2008 17:57
47 lines
3102 bytes
3102 bytes
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?
Many thanks in advance,
Mike
Technical Details
Message-ID:
<4855474a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nlpi057.nbdc.sbc.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!news-xxxfer.readnews.com!207.99.111.53.MISMATCH!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a169c88c9ed98680,start X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Mike Collins" <its@TheBottomOfThePost> Newsgroups: borland.public.cppbuilder.nativeapi Subject: CreateProcessAsUserW and quoted path names... Date: Sun, 15 Jun 2008 17:57:26 -0000 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 NNTP-Posting-Host: 78.148.84.185 Message-ID: <4855474a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1213548362 78.148.84.185 (15 Jun 2008 09:46:02 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nlpi057.nbdc.sbc.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!news-xxxfer.readnews.com!207.99.111.53.MISMATCH!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail