|
Thanks, but it seems a bit complex for me..
Is there an alternative without having to use an object?
I'm relatively new to c++ and I haven't used objects in my program so far.
|
|
|
|
|
Well in that case you've got a lot of reading ahead of you!
Yes, you can do this without using classes, *but* the core technique outlined in the article really is the only good way to do this, as it properly deals with concurrency issues that many of the other approaches don't deal with, at least for an app that has a GUI. If you don't have a GUI then you may not need something as sophisticated.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Here's my solution:
class MultipleInstance {
public:
MultipleInstance();
~MultipleInstance();
static bool Active();
private:
static bool _Active;
static bool _Initialized;
static HANDLE _Handle;
static MultipleInstance *_Instance;
};
static MultipleInstance _MultipleInstance;
bool MultipleInstance::_Active = false;
bool MultipleInstance::_Initialized = false;
HANDLE MultipleInstance::_Handle = NULL;
MultipleInstance *MultipleInstance::_Instance = &_MultipleInstance;
MultipleInstance::MultipleInstance()
{
if ((!_Initialized) && (this == _Instance)) {
SECURITY_DESCRIPTOR security_descriptor = { 0 };
InitializeSecurityDescriptor(&security_descriptor,
SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&security_descriptor,TRUE,NULL,FALSE);
SECURITY_ATTRIBUTES security_attributes = { 0 };
security_attributes.nLength = sizeof(security_attributes);
security_attributes.lpSecurityDescriptor = &security_descriptor;
security_attributes.bInheritHandle = FALSE;
SetLastError(0);
_Handle = ::CreateSemaphore(&security_attributes,0,1,
_T("Global\\InstanceSemaphore"));
if (GetLastError() == ERROR_ALREADY_EXISTS) {
_Active = true;
}
_Initialized = true;
}
}
MultipleInstance::~MultipleInstance()
{
if (_Initialized && (this == _Instance)) {
if (_Handle != INVALID_HANDLE_VALUE) &&
(_Handle != NULL)) {
CloseHandle(_Handle);
_Handle = NULL;
}
}
}
bool MultipleInstance::Active()
{
return _Active;
}
|
|
|
|
|
Hi, many many thanks for the advice but not being familiar to oject programming I am missing some crucial bits to make it work.
In MultipleInstance.h what name should I give to:
#ifndef
#define
Is there anything else I need to specify?
In MultipleInstance.cpp I have specified:
#include <iostream>
#include "MultipleInstance.h"
Is anything else needed?
In the main cpp file:
What is the correct syntax I need to use to call the object?
Should I insert it immediately after
int _tmain(int argc, _TCHAR* argv[]){
|
|
|
|
|
I am using CFTPConection class.
While uploading file via PutFile() function I also want to display
the destianion file size i.e. data uploaded up to perticaulr instant.
I could not make the connetion for that file as it is uploding i.e. it's open for writting.
So is there any way to check how much data transferred up to perticuar time. This value amy be in number of bytes.
Or is there is any othere option rather than Putfile() which uses buffer so that I can check buffer size..
please help me for this..
Thank you so much..
|
|
|
|
|
Hai all,
Can anyone suggest me how to set a blank date as the initial value for date time picker control?
I did as per the article : http://support.microsoft.com/kb/q238077/ [^]
I am currently using VC++ 6.0 and i get the following errors:
error C2039: 'SetCustomFormat' : is not a member of 'CDateTimeCtrl'
d:\program files\microsoft visual studio\vc98\mfc\include\afxdtctl.h(39) : see declaration of 'CDateTimeCtrl'
Is there any other way to do so?
Priya Sundar
|
|
|
|
|
Hi,
The steps 1,2,3 mentioned in top may be for MS Date Time Picker Activex control and steps 1 & 2 bottom could be for the Windows Date Time Picker.
You try the steps 1 & 2 at bottom.
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Still it didnt work after doing step 1 and 2.
And fyi.. the if we do setwindowtext with empty text, then in that case itself we dont set a blank date, instead the the control displays the current system time with a default format.
Priya Sundar
|
|
|
|
|
Hi,
If you have not yet solved the problem, please post it as new message again.
It will be better posting your code.
It may be a programming bug or VC++.
Have you tried other styles[^]other than DTS_SHORTDATEFORMAT?
It seems there are some problem already related with Datetimecontrol: DateTimePicker Format changes from Time to Short Date[^]
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Hello everyone,
When we have cross-apartment call (inside one process) from ... to ...,
1. STA --> MTA;
2. MTA --> STA.
In both cases we must use either GIT (global interface table) or CoMarshalInterThreadInterfaceInStream?
If call method on destination apartment through interface pointer of component of destination apartment directly is violation (bypass the above two methods)?
(for example, sharing raw interface pointer directly in global variable and call methods on interface pointer directly)
thanks in advance,
George
|
|
|
|
|
George you've started learning COM ? Dangerous! You got rid of STL atlast? Or STL got rid of you? .
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
Thanks Maximilien,
Any ideas to my original question?
regards,
George
|
|
|
|
|
Hi VuNic,
I use STL, COM and ATL, and I am also learning C#. Any ideas to my original question?
regards,
George
|
|
|
|
|
Hello everyone,
Once I thought all calls across COM apartments (not inside apartment) are all synchronous call, now after study re-entrancy problem, I think I am wrong, at least STA to MTA call is asynchronous.
(Link to re-entrancy problem, http://www.codeproject.com/KB/COM/sta_issues.aspx)
After some study, I can not find a conclusion whether the 4 types of calls are synchronous or asynchronous. Here is my study result, please feel free to correct me if I am wrong?
1. STA --> STA, I think asynchronous;
2. STA --> MTA, I think asynchronous;
3. MTA --> STA, I think synchronous;
4. MTA --> MTA, I think synchronous.
thanks in advance,
George
|
|
|
|
|
Hi all,
In SDI type of application how can show application in Maximize mode and Fix it.
i m using this "ShowWindow(SW_MAXIMIZE);" in .cpp file of application,but it is not working properly.
it show application in maximize but restore also.
please anyone help me for this.
Thanks in advance.
|
|
|
|
|
Hi,
Is this solve the problem?
<br />
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);<br />
m_pMainWnd->UpdateWindow();<br />
Thanks
--
"Programming is an art that fights back!"
|
|
|
|
|
no is not solved out my problem because use of this widow open as maximize but restore also.
|
|
|
|
|
rp_suman wrote: m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
hi i m already try this but it is not working.
it is only initially maximize the window, and restore too.
but i want window should be maximize all the time and it not restore.
thanks.
|
|
|
|
|
|
In my simple win32 pgm I launch Notepad,
CreateProcess("c:\\winnt\\notepad.exe"...
then get a handle to it,
hwndTarget = FindWindow(NULL, TEXT("Untitled - Notepad"));
then close it with no problem,
SendMessage(hwndTarget, WM_CLOSE, 0, 0);
But if instead of closing it I try to Post/Send it a character to display
PostMessage (hwndTarget, WM_CHAR, 'x', 1) ;
SendMessage (hwndTarget, WM_CHAR, 'z', 1) ;
it doesn't work.
So I'm missing something here, but don't know what it is.
Thanks for any assistance!
glyfyx
|
|
|
|
|
The problem is that you're sending the messages to the main window.
Maybe the edit control that processes the chars is a child window of the main. You can find it with spy++.
Hope it helps
rotter
The metaller programmer
|
|
|
|
|
Thanks rotter - I believe that's it!
I used Spy++ (for the first time!) and found what looks very much like a child window and its handle under Notepad. Now what I have to do is figure out how to obtain the child's handle in my code then send WH_CHAR to it.
Big help - thanks!
glyfyx
|
|
|
|
|
I'm writing a custom PE loader, and I finished everything except relocations, which I can't find anywhere in the EXE. I'm using Windows's notepad.exe as my initial test. Both the BASERELOC directory entry (DataDirectory[5]) and the PointerToRelocations field of the .text section are set to all 0's. Also, there is no ".reloc" section. Any ideas where these relocations would be located?
|
|
|
|
|
Anyone? A possibility is that modern compilers assume the base image address will never change, and forego creating relocations. Can anyone confirm or deny this?
|
|
|
|