|
No implicit linking
Dll a links to dll b via function call
Dll b creates obtjects via new operator stores pointer at dll d (structure that was exported)
Dll e calls dll b via function call and dll b tries to retrive the pointers from the structure that was exported but the value is zero
I was wondering what is the duration of storage allocated via the
"New" operator
|
|
|
|
|
ForNow wrote: I was wondering what is the duration of storage allocated via the
"New" operator
Should be until correnponding cleanup happens(i.e. delete call) hence it should stand well-alive until your process ends.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Maybe I'll put the pointer under "Watch" and see when it disappears
Thankx
|
|
|
|
|
i know this has been done, ive seen examples i just cant seem to figure it out, how if at all can i create an object outside the form, say on the desktop? any help is appreciated, thanks. Oh i use Borland if that helps any...
|
|
|
|
|
codeinelogic wrote: say on the desktop?
Try using the window handle of the Desktop as the parent window to the window you are creating.
led mike
|
|
|
|
|
If you need to paint outside the application window use a screen device context (obtained via GetDC(NULL) ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I have written an application using Visual Studio 6 C++, targeted for Windows XP and 2000. How do I detect/prevent multiple instances of my program?. I only want a single instance running and every time I click the shortcut, I get another instance launched (Duh!).
|
|
|
|
|
I use this:
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
return;
}
You can place this code in InitInstance() for example.
|
|
|
|
|
Works like a charm.. (as if you needed me to tell you)
Thanks!
|
|
|
|
|
|
Michael,
Not everything Dr. Newcomer has written is correct in that article. He fails to mention the Global Local and Session namespace types of kernel objects.
http://msdn2.microsoft.com/en-us/library/aa382954(VS.85).aspx[^]
I find that some of his articles fail to address features of modern operating systems such as Vista and even some features of XP. If the goal of the original poster is to limit his application to an absolute single instance then the above code is perfectly sufficient by simply declaring the Mutex as global.
By adding a prefix of "Global\\" to the Mutex there is absolutely no way another instance of the application will be created. In addition, if you look at the bottom of the article by Dr. Newcomer he presents large functions to limit the application to session and global both of which can be achieved by simply prefixing the Mutex with "Global\\" , "Local\\" or "Session\\".
Conversely, if the goal of the original poster is to have maximum flexibility then perhaps the code Dr. Newcomer has presented would be better. Although I would personally modify it to use the kernel object namespaces.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: Not everything Dr. Newcomer has written is correct in that article.
Incorrect or just outdated?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi DavidCrow,
Outdated would have been a better way to describe the techniques presented in the article by Dr. Newcomer. I don't think kernel object namespaces were documented when the article was written. I am a big fan of Joseph Newcomer and have absolutely enjoyed reading his essays over the years. His website is an absolute treasure trove of Win32 information.
Best Wishes,
-David Delaune
|
|
|
|
|
This has been done many times before.
Basically, in your WinMain() or _tmain() try to open a mutex with OpenMutex() , if it fails then create it (CreateMutex ).
If OpenMutex() succeeds then it means your application is already running. You can do a search here on CP, you will find several examples in MFC, C++ and .NET.
Good luck
God bless,
Ernest Laurentin
|
|
|
|
|
|
Hi,
I want to program an ActiveX control in web page such that user can access (save and open) the local PC files and connect to the internet via http, is it possible ? Are there any limitation for an ActiveX Control in Web page similar to java applet ?
Thanks
Dolphin
|
|
|
|
|
dolphinhk wrote: Are there any limitation for an ActiveX Control in Web page similar to java applet ?
No, and if there was any information about that you would certainly not find it on the MSDN Web Site[^]
led mike
|
|
|
|
|
dolphinhk wrote: Are there any limitation for an ActiveX Control in Web page
Cross platform compatibility (lack of) comes immediately to mind...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
How to create an Application which have a singleton class which herit form 3 other interface class (so with pure virtual functions), without loosing reference to these interface functions ?
My problem is that I am lossing reference to vftable(__vfptr) between instances, so I cannot access to my interfaces in another instance of the application.
More about this problem :
1 - I launch "MyClass.exe start" => OK "MyClass.exe" is running ...
2 - I launch "MyClass.exe configure" => access violation is raised, because can't access to MyClass->Configure().
NB: this problem not occur if I make -2- then -1-
And although I call Configure() inside Start() it's working well.
My implementation code is :
<br />
#include "MyClass.h"<br />
#pragma data_seg("MyShared")<br />
MyClass* MyClass::m_instance = 0;
#pragma data_seg()<br />
#pragma comment(linker, "/section:MyShared,rws") <br />
<br />
int main(int argc, char *argv[])<br />
{<br />
MyClass* Me= MyClass::Instance();<br />
if(argc==2)<br />
{<br />
if(strcmp(argv[1],"start")==0)<br />
{<br />
MyClass->Start();
return 1;<br />
}<br />
<br />
if(strcmp(argv[1],"stop")==0)<br />
{<br />
C3STrace(C3S_TRACE_DEBUG, C3S_TRACE_INFO, "MAILNOTIFIER_STOP");<br />
MyClass->Stop();
return 2;<br />
}<br />
<br />
if(strcmp(argv[1],"configure")==0)<br />
{<br />
MyClass->Configure();
return 3;<br />
}<br />
}<br />
return 0;<br />
}<br />
<br />
-------------------------------------<br />
class MyClass: public Interface1, public Interface2, public Interface3<br />
{<br />
....<br />
static MyClass m_instance;<br />
static MyClass* Instance();<br />
virtual void Configure();<br />
}<br />
-------------------------------------<br />
MyClass* MyClass::Instance()<br />
{ <br />
if( m_instance == NULL )<br />
m_instance = new MyClass(); <br />
return m_instance;<br />
}<br />
--------------------------------------<br />
void MyClass::Configure()<br />
{<br />
}<br />
--------------------------------------<br />
Regards,
Olivier.
|
|
|
|
|
Does this compile?
class MyClass
{
static MyClass m_instance;
}
MyClass* MyClass::m_instance = 0;
and this
MyClass->Start();
I'm also doubtful about the use of shared data segment memory as an interprocess mechanism.
|
|
|
|
|
hi all
I need to handle a notification event from Active Directory server.
when the user deletes, renames, moves or changes the properties of an object using one of the Active Directory.
I am writing a com component derived from IDsAdminNotifyHandler Interface
and waiting for the notification event in Notify function of the interface
but the notification never occurs when the user details are changed.
plz help me.
thank & regards
#sanroop#
|
|
|
|
|
I have faced problem with cl_login. Whether it is standard function?
Please if anyone have any idea tell me.
|
|
|
|
|