|
You can also try to use thread-save lists. I think there are some at www.stlport.org.
Hardy.
|
|
|
|
|
Hi,
I have an application in VC++ 6.0 and Hierarchial database files for working. Plz Note, Here I am not connecting my application to any database, insteed I am using the Hierarchial database files for my application.
1. First I start my application and open the database file using open menu which intern generates the XML files from database files. On "save" the data is saved in "Workspace"
Next time when I start the application it loads the last recently saved workspace.
2. Now I starts one more instance of same application i.e. second instance of same application. Here it loads the last saved workspace (same workspace is opened in first instance ). So working on same workspace in two different instaces is dangerous for data.
I want to restrict the second instance from loading the workspace if it is already loaded in previous instance.
Also, I should be able to work on different workspaces in different application instances.
Q: How to manage this?
Plz send any samples, codes, ideas to me
Thanx for your valuable help and support.
Thanks & Regards,
Neeraj
|
|
|
|
|
Are you saving 'Workspace' as file? If yes, then while opening workspace file, open it in exclusive mode, so that access is denied to second instance of your application. For example if you are usinf CFile to open workspace use:
CFile file;
file.Open("workspace", CFile::shareExclusive|CFile::modeReadWrite);
ARSALAN MALIK
|
|
|
|
|
Thanx Malik,
I will try this and get back to you.
Thanks & Regards,
Neeraj
|
|
|
|
|
Hi
If you want to allow only one instance of your application. You can use mutex.
Create a mutex object with specific name in initinstance. If mutex creation fails means another instance is open.
Regards,
prashant
|
|
|
|
|
Use Mutex to restrict only one instance of application.
Create mutex with specific name in initinstance.
If function failed your application is already running
prashant
Regards,
Prashant
|
|
|
|
|
Thanx prashant.
Can you send me some sample code for that?
Thanks & Regards,
Neeraj
|
|
|
|
|
SECURITY_ATTRIBUTES secAttributes ;
secAttributes.nLength = sizeof (SECURITY_ATTRIBUTES);
CreateMutex (&secAttributes, TRUE, "PRASHANT" );
if (GetLastError () == ERROR_ALREADY_EXISTS)
{
::MessageBox (NULL, "Application is already running.", "PRASHANT", MB_OK | MB_ICONEXCLAMATION);
return 1;
}
Regards,
Prashant
|
|
|
|
|
Thanx Prashant.
Where exactly I have to put this code in Initinstance?
Can you give me complete Initinstance code?
Thanks & Regards,
Neeraj
|
|
|
|
|
It can be the first statement of initinstance
BOOL CMyApp::InitInstance()
{
SECURITY_ATTRIBUTES secAttributes ;
secAttributes.nLength = sizeof (SECURITY_ATTRIBUTES);
secAttributes.lpSecurityDescriptor = NULL ;
secAttributes.bInheritHandle = FALSE ;
CreateMutex (&secAttributes, TRUE, "prashant");
if (GetLastError () == ERROR_ALREADY_EXISTS)
{
::MessageBox (NULL, "Application already running", "Prashant",MB_ICONEXCLAMATION);
_exit(0);
}
//Rest of the code of initinstance
}
Regards,
Prashant
|
|
|
|
|
Prashant thanx a lot.
It's working fine. Poping the message "Application already running" when I try to start the second instance of the application.
Still what I need is, when I click the message box "Application already running", the first instance of application should be displayed on the screen.
Thanks & Regards,
Neeraj
|
|
|
|
|
Hi there
How to add a toolbars to a win32 application?
Thanks
|
|
|
|
|
|
hi,
my module is to enable the comports which r present in the system.
For eg: if COM port1 & 3 r present in my system, then 1 & 3 should be enabled in my menu bar.
void CComDlg::OnUpdateport2(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(port3==1)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
Is this the correct method to enable the port which is present in the system?
But it is not working.
Pls help.
Mithila
mithila
|
|
|
|
|
hi,
pls help any one.
mithila
|
|
|
|
|
Hi,
What I understand from your question is that you want to work with com ports, right ? then, I think you should use GetCommState and SetCommState api after fillig in the DCB.
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
|
Does anyone know of any articals or examples that show how to change the defualt icon of an exe?
(if you say the words "resource editor" i will come to your house, chop your legs off, set your house on fire and watch as you drag your bloody stumps out door, nah im just keeding)
|
|
|
|
|
Are you coding with MFC or not?
|
|
|
|
|
well i would prefer that it not use mfc so i could use in other non-mfc projects too, but i will be using MFC to make that app yes,
|
|
|
|
|
Well, not using MFC, you can set your icon when you register your window class with WNDCLASSEX
<br />
WNDCLASSEX wc;<br />
wc.hIcon = LoadIcon(HandleToYourInstance, "IDI_YOURAPPICON");<br />
There are a couple other things in WNDCLASSEX that you can set to customize your program.
In MFC, go to your CWnd class's constructor and initialize the m_hIcon member:
<br />
m_hIcon = AfxGetApp()->LoadIcon(IDI_YOURAPPICON);<br />
Voila.
augy
|
|
|
|
|
Im sorry thats not what i was looking for
that is how to change the icon of the window(which i already knew), I want to know how to progmatically change the default icon of an exe, the way a resource hacker would. and when i say the default icon of the exe im talking about the icon that would be showing up in explorer.
|
|
|
|
|
oooooh. How does explorer decide what icon to display? It will automatically pull the main window's icon out and use that as the display icon, at least if it's compiled in MFC (or MFC is packaging the EXE with explorer information in it). Short answer: no f*ing idea.
augy
|
|
|
|
|
To change icon of an exe, you need to overwrite it's icon resource. But first you need to determine default icon, to do that you need programs like Resource Hacker. Once you have found ID of default icon, you can easily update resource. Just follow this article and MSDN.
ARSALAN MALIK
|
|
|
|
|
Archer282 wrote:
Does anyone know of any articals or examples that show how to change the defualt icon of an exe?
Well the "default" icon, the one shown by explorer, is always the first icon in the executable file. So all you have to do is edit the first icon. Is the icon in your executable? If so, use the resource editor. If it's in a separate executable, you'll need to use the BeginUpdateResource() etc. methods to access it at runtime.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|