|
Take care if you place it in a DLL you have to distinguish action done in the DLL:
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved // reserved
)
{
BOOL fInit = FALSE;
WORD wVersionRequested;
WSADATA wsaData;
// Register the log
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
...
case DLL_THREAD_ATTACH:
...
case DLL_THREAD_DETACH:
...
case DLL_PROCESS_DETACH:
...
};
What is the goal of your mutex ?
Prevent multiple loads of the DLL or block for security reasons ?
Tell me more...
|
|
|
|
|
Hi
Migounette wrote: What is the goal of your mutex ?
Prevent multiple loads of the DLL or block for security reasons ?
Tell me more...
The Goal is to ensure that at most one copy each of a suite of four apps is running per machine. A function 'OnceOnly()' is exported from the DLL. So, instead of the function 'OnceOnly()' being separately included in each of the Apps, it was moved to the DLL which contains the 'Common' Code for the Apps.
The Full Code for OnceOnly() is:-
<br />
DLLEXPORT void OnceOnly(){<br />
CString AppName=GetAppRootName();<br />
CString MutexName=AppName+SG_UID;<br />
<br />
HANDLE exclusion = CreateMutex(NULL, FALSE, MutexName);<br />
DWORD err = ::GetLastError();<br />
if(err != 0){<br />
if(err == ERROR_ALREADY_EXISTS){<br />
CString Message;<br />
Message.Format("There is already an Instance of '%s' Running on This Computer\n\n"<br />
"Activate the Existing Instance instead",(LPCSTR)AppName);<br />
AfxMessageBox(Message);<br />
exit(0);<br />
}<br />
else{<br />
AfxMessageBox("An Error occurred whilst checking that No other instance of\n"<br />
"this program is running\n");<br />
exit(-1);<br />
}
}<br />
Thanks
Bram van Kampen
|
|
|
|
|
Dear All,
I am still new in c++
i would like to implement this class
how??
void main()
}
;(A a1(1,1
;(A a3(2,2
;(A a3(0,0
a3=a1+a2;
++ a1
() a3.out
a3=a1-a3
{() a3.out
Yes. CreatiVity withOuT limiTs
modified on Friday, December 11, 2009 3:57 PM
|
|
|
|
|
This doesn't look like C++ to me.
|
|
|
|
|
its like procedure must be implemnt in c++
Yes. CreatiVity withOuT limiTs
|
|
|
|
|
I think he want's to port it over to C++, or maybe it's some sort of class diagram outlining functionality...
|
|
|
|
|
Do you want to convert ASCII-art into C++ code?
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
[My articles]
|
|
|
|
|
yes, and without limits please.
|
|
|
|
|
#include <iostream>
using namespace std;
class A
{
private:
int x;
int y;
public:
A()
{
x = 0;
y = 0;
}
A(int First, int Second)
{
x=First;
y=Second;
}
// Opertator
// A operator= ( A &oA);
A operator- ( A oA);
A operator+ ( A oA);
A& operator++(int unu); // prefix
int GetMyX() { return x; }
int GetMyY() { return y; }
void SetMyX(int Xvalue)
{
x=Xvalue;
}
void SetMyY(int Yvalue)
{
y=Yvalue;
}
void Out()
{
cout<<"Value Of x:" << GetMyX()<<" "<<"Value Of y:"<<GetMyY()<<endl ;
}
};
A A:: operator- (A oA)
{
oA.SetMyX (oA.GetMyX ()-x);
oA.SetMyY (oA .GetMyY ()-y);
return oA;
}
A A::operator+ (A oA)
{
oA.SetMyX (oA.GetMyX ()+x);
oA.SetMyY (oA .GetMyY ()+y);
return oA;
}
A& A::operator++(int temp)
{
SetMyX (GetMyX ()+1);
SetMyY (GetMyY ()+1);
return *this;
}
int main()
{
using namespace std;
A a1(2,4);
A a2(3,6);
A a3(0,0);
a1++;
a1.Out ();
a3=a1+a2;
a3.Out ();
a3=a1-a3;
a3.Out ();
int x;
cin>>x;
return 0;
}
Yes. CreatiVity withOuT limiTs
|
|
|
|
|
Is there a question in there? It's just a bunch of code although it does look like C++ this time.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Could you at least be bothered to fix this so it is legible? Did you use the Preview button before posting?
"One man's wage rise is another man's price increase." - Harold Wilson
"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,
It is a code for a robot i want code take vedio from usb cam and make it frams(pics) as i could use it later @ another code the code is in C++ i found one but there is a compiler error it is little but i canot fixed it
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
IplImage* src = NULL;
int _tmain(int argc, _TCHAR* argv[])
{
int key;
CvCapture* capture = NULL;
if(NULL==(capture = cvCaptureFromCAM(-1)))
{
printf("\nError on cvCaptureFromCAM");
return -1;
}
cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Capture2", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Capture", 50, 50);
cvMoveWindow("Capture2", 320, 50);
for(;;){
if(NULL==(src=cvQueryFrame(capture))){
printf("\nError on cvQueryFrame");
break;
}
cvShowImage("Capture", src);
key = cvWaitKey(10);
if(key==0x1b)
break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Capture");
return 0;
}
|
|
|
|
|
It's hard to tell what the problem is. Where are the "cv.h" and "highgui.h" files? Can you post the complete error message here?
|
|
|
|
|
highgui.h and cv.h are headers from the openCV[^] library.
Asmaa, if there is a compile error you will need to tell us what it is. We aren't psychic.
|
|
|
|
|
What is the compiler error? No one is going to type in your code and try to compile it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
do you have opencv installed on your system?
if(no){install opencv;}
add opencv include and source directories to your compiler setting and at the end
add the libraries in your project setting
|
|
|
|
|
example:
double 5 cover to '5'.
|
|
|
|
|
doubles typically don't fit in one char, however you can easily convert them to string.
that is so basic, is this your first day at programming?
I hope you are wise enough to learn from a book, study it from front to where ever you get, and look at examples and exercises.
The exact answer depends on the language you use, which you did not specify.
in good old C you could do it with an sprintf() or swprintf()
Here[^] is one page of doc, even wikipedia knows how!
Please make Google your daily friend.
modified on Friday, December 11, 2009 2:51 PM
|
|
|
|
|
Sorry to say, I think you misunderstood the OP request: he wants to cover the double with a char . This is usually possible, provided the char is by repeated as needed. For instance consider the double 0.75 :
if you repeat the char '*' four times over it, then you obtain a very good coverage.
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
[My articles]
|
|
|
|
|
No problem, Microsoft invented a class[^] for that very purpose.
|
|
|
|
|
Nah, (Heretic!) that's for managed development.
Furthermore, as usual, they didn't invent it, just stolen it from Java...
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
[My articles]
|
|
|
|
|
I guess you probably mean convert; take a look at sprintf[^] and its variants.
|
|
|
|
|
i have an double array u[100].
this code print "Hello 123" to openGL window, can i print u like this?
static char sbuff[20];
wsprintf(sbuff,"Hello %d",123);
OutText(0,yMax - 10,sbuff,GLUT_BITMAP_8_BY_13);
void OutText(float x,float y,char *text,void *font)
{
glRasterPos2f(x,y);
for(int i=0;text[i]!=0;i++)
{
glutBitmapCharacter(font,text[i]);
}
glutPostRedisplay();
}
|
|
|
|
|
This looks good, did you have a question about it?
|
|
|
|
|
Hi folks!
Can anyone kindly tell me how to convert _variant_t to char*?
Thanks!
char Buf[100];
_variant_t var;
?
|
|
|
|