Click here to Skip to main content
15,921,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: where does the command line pass the file name? Pin
Hesham Amin4-Jun-04 7:53
Hesham Amin4-Jun-04 7:53 
GeneralRe: where does the command line pass the file name? Pin
Paul Harter4-Jun-04 10:51
Paul Harter4-Jun-04 10:51 
AnswerRe: where does the command line pass the file name? Pin
palbano4-Jun-04 8:11
palbano4-Jun-04 8:11 
GeneralRe: where does the command line pass the file name? Pin
Paul Harter4-Jun-04 10:54
Paul Harter4-Jun-04 10:54 
GeneralGet the index when clic in a ListCtrl Pin
doctorpi4-Jun-04 7:14
doctorpi4-Jun-04 7:14 
GeneralRe: Get the index when clic in a ListCtrl Pin
Rodrigo Pinto Pereira de Souza4-Jun-04 7:39
Rodrigo Pinto Pereira de Souza4-Jun-04 7:39 
GeneralRe: Get the index when clic in a ListCtrl Pin
doctorpi4-Jun-04 8:14
doctorpi4-Jun-04 8:14 
GeneralClose An Instance of an Application Pin
Grahamfff4-Jun-04 6:18
Grahamfff4-Jun-04 6:18 
I have an application for which up to 4 instances of it can be fired up.

Now to close an instance of the application another application fires an named event; e.g. closeInstance3.

I use this piece of code for each application to determine what instance it is:
n = __argc;// and __argv
// if n > 1 then instance is specified, otherwise default to IDU 1
if (n > 1)
{
if(n == 2)
{
instanceID = 1;
}
if(n == 3)
{
instanceID = 2;
}
if(n == 4)
{
instanceID = 3;
}
if(n == 5)
{
instanceID = 4;
}
}
else
instanceID = 1; // default

This is because I use the following to start (in this instance 3)
GetStartupInfo(&si[2]);
CreateProcess(NULL, "c:\\Program Files\\Prog.exe 3 3 3", // Name of app to launch; 3 params of 3 = instance 3
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si[2], // Startup Information
&pi[2]); // Process information stored upon return

The main dialog accesses this variable via the following:
// The instance of this program( range 1 to 4)
extern int instanceID;

I have defined a class member as such:

volatile int m_nProgID;

My question is how do I have the thread which receives events (one of which will be to close this instance of the application) access this variable m_nProgID. I thought volatile would have worked?

Each instance of the program will define (or get a handle) for its close event; i.e. instance 2 will get a handle on event closeInstance2. They use m_nProgID in a switch to get a handle on the event they need to deal with; but it seems that m_nProgID is always 1 in the Thread that handles the events.

Instance 1 closes OK, but default for instanceID is 1. The other instances dont


grahamfff
QuestionHow to set the Tooltips width? Pin
Cyrus Dang4-Jun-04 5:45
Cyrus Dang4-Jun-04 5:45 
QuestionCMemFile Buffer size?? Pin
P_JAYAPRAKASH4-Jun-04 4:32
P_JAYAPRAKASH4-Jun-04 4:32 
GeneralSecure Connection between Mysql Server and C++ Client Pin
Alex H 19834-Jun-04 4:26
Alex H 19834-Jun-04 4:26 
GeneralRe: Secure Connection between Mysql Server and C++ Client Pin
markkuk4-Jun-04 6:24
markkuk4-Jun-04 6:24 
GeneralSpin Control and SetBase(16) question Pin
Like2Byte4-Jun-04 4:26
Like2Byte4-Jun-04 4:26 
QuestionOrphaned mutexes--how to release? Pin
dandy724-Jun-04 4:20
dandy724-Jun-04 4:20 
AnswerRe: Orphaned mutexes--how to release? Pin
bikram singh4-Jun-04 7:11
bikram singh4-Jun-04 7:11 
GeneralRe: Orphaned mutexes--how to release? Pin
dandy724-Jun-04 8:36
dandy724-Jun-04 8:36 
GeneralRe: Orphaned mutexes--how to release? Pin
Blake Miller4-Jun-04 14:05
Blake Miller4-Jun-04 14:05 
GeneralRe: Orphaned mutexes--how to release? Pin
dandy727-Jun-04 7:40
dandy727-Jun-04 7:40 
QuestionHow to use CInternetFile::WriteString() Pin
brdavid4-Jun-04 4:13
brdavid4-Jun-04 4:13 
Questionhow to use control in a dialog Pin
laia4-Jun-04 3:20
laia4-Jun-04 3:20 
AnswerRe: how to use control in a dialog Pin
toxcct4-Jun-04 5:54
toxcct4-Jun-04 5:54 
GeneralRe: how to use control in a dialog Pin
laia4-Jun-04 6:15
laia4-Jun-04 6:15 
GeneralSetWindowLong Returns negative Value. Pin
Abhi Lahare4-Jun-04 2:56
Abhi Lahare4-Jun-04 2:56 
GeneralRe: SetWindowLong Returns negative Value. Pin
toxcct4-Jun-04 3:05
toxcct4-Jun-04 3:05 
QuestionHow to get record from a table in Access Pin
yingkou4-Jun-04 1:51
yingkou4-Jun-04 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.