roger5089
March 21st, 2006, 08:38 AM
Dear all
does any function code i can use in c++ programmer
to avoid user second time to client you exe file
does any function code i can use in c++ programmer
to avoid user second time to client you exe file
|
Click to See Complete Forum and Search --> : How to avoid user second client you exe file roger5089 March 21st, 2006, 08:38 AM Dear all does any function code i can use in c++ programmer to avoid user second time to client you exe file Brenton S. March 21st, 2006, 01:40 PM I really don't understand the question. Can you be more clear? VladimirF March 21st, 2006, 04:34 PM Dear all does any function code i can use in c++ programmer to avoid user second time to client you exe file Is this what you are asking? How can I limit my application to one instance? (http://www.codeguru.com/forum/showthread.php?t=312467) roger5089 March 21st, 2006, 08:12 PM Yes something like that , but i donot know why when i edit that code into my program it will can make other Instance //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; AnsiString me; AnsiString change; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } int TForm1::InitInstance() { HANDLE mutex = CreateMutex(NULL, false, "TForm1"); DWORD error = GetLastError(); if(error == ERROR_ALREADY_EXISTS && mutex!=NULL ){ HANDLE TheSame; if( (TheSame=FindWindow("TForm1","Form1"))!=NULL ){ PostMessage( TheSame, // handle of destination window 0x1700, // message to send 0, // first message parameter 0 // second message parameter ); } } return 0; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { me = "this is roger"; Memo1->Lines->Text = me; TForm1::InitInstance(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Memo1Change(TObject *Sender) { change = Memo1->Lines->Text; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { ShowMessage(change); // MessageBox(NULL,"TEXT",change,MB_OK); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { exit(8); } //--------------------------------------------------------------------------- humptydumpty March 21st, 2006, 08:55 PM Did u mean that user can't create second instance of your application. if yes Simply uSe Singelton Class Concept. So user can't create more then One instance of your Application. Thanx. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |