🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: CommandLine Parameter to own Application...

#9783
From: Remy Lebeau (TeamB)
Date: Mon, 07 Jun 2004 18:47
45 lines
2407 bytes
"Oren Halvani" <NoSpam@fdtd.com> wrote in message
news:40c49e06@newsgroups.borland.com...

> for handling this i've putted the following in
> my project... my problem is..it doesn't work!

You should know better by now that just saying "it doesn't work" says
nothing at all about the actual problem you are having.  Are you receiving
the message at all?  If so, does it contain the proper filename that you are
expecting?

>   S = S + '\0';

You don't need to add the null terminator, it is already present in the
original data.

>         HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, "MyApp");  // Try
to
> open the mutex.
>
>         if(!hMutex) hMutex = CreateMutex(0, 0, "MyApp");  // If hMutex is
0
> then the mutex doesn't exist. Create it.

You don't need to call OpenMutex() at all, just call CreateMutex() only.  If
the mutex already existed, CreateMutex() will return the existing mutex and
GetLastError() will return ERROR_ALREADY_EXISTS.

>            HWND hWnd = FindWindow(0, "MyApp"); // This is a second
instance.

Make sure that you set Application->Title to "" first so that FindWindow()
does not find the new instance that is being launched.

>               COPYDATASTRUCT cds;
>               cds.cbData = strlen(cmdLine) + 1;
>               cds.lpData = cmdLine;

You need to make sure that the command line does not contain the
executable's own filename at the front.  Depending on how the application is
being launched, it very well may.


Gambit
Technical Details
Message-ID: <40c4b952$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40c49e06@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e90b072bab983bf1
X-Google-Attributes: gid10cc67,public
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40c49e06@newsgroups.borland.com>
Subject: Re: CommandLine Parameter to own Application...
Date: Mon, 7 Jun 2004 11:47:52 -0700
Lines: 47
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.169.168.124
Message-ID: <40c4b952$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1086634322 68.169.168.124 (7 Jun 2004 11:52:02 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail