|
I knew that it would be difficult to explain. You are right that it is also difficult for you to understand where exactl the problem is.
But can you please throw light in some other direction. Suppose i want to execute a particular application after it is downloaded. Is it possible for executable file that is being downloaded to execute itelf after its complete downloading or from server where it is being downloaded, can we do at that side (server) to execute it.
I may be silly asking such question but this kind of question arises when i think of spyware and viruses. Because nobody tell them to execute but they maliciously run after being downloaded.
So please further share your knowledge.
Thanks & Regards,
Hemang
Thankd
|
|
|
|
|
An binary will not be able to execute 'itself' after it's been downloaded. You either need a watchdog which will be monitoring the download to execute it upon completion. But as you already say that it is your own application that does the download, it could as well execute the file after download. If there are issues on specific computers, try logging the events from your application and find out what is causing this problem. You can use an external debugger like DebugView[^]to print debug strings (the name is misleading, works on release versions as well) if you wish not to use a log file.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I really thankful to you. I will have look at DebugView. But once again thank you. I am obliged.
Thanks & Regards,
Hemang
|
|
|
|
|
You're most welcome. And I forgot to mention: The API which prints to DebugView is OutputDebugString. Look it up in MSDN.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
how to get process start time in vc?
wqewqqeweqwrwerewrwe
|
|
|
|
|
Use GetProcessTimes() or Sample Code[^]. Hope this helps and is relevant to your needs.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Will API GetProcessTimes helpful ?
Regards,
Paresh.
|
|
|
|
|
See here[^] for your answer and other info.
|
|
|
|
|
I created a dll file like this :
HHOOK MyHook;
HINSTANCE MyInstance;
LRESULT CALLBACK MyMouseHookProc(int nCode, WPARAM wParam, LPARAM lParam);
extern "C" __declspec(dllexport) void Hook();
extern "C" __declspec(dllexport) void Unhook();
BOOL CMouseHook1App::InitInstance()
{
CWinApp::InitInstance();
MyHook = NULL;
MyInstance = this->m_hInstance;
return TRUE;
}
void Hook()
{
if(MyHook == NULL && MyInstance != NULL )
{
MyHook = SetWindowsHookEx(WH_MOUSE,MyMouseHookProc,MyInstance, 0);
if(MyHook!= NULL)
MessageBox(NULL,_T(" HOOKED "), _T(""),0);
}
else
MessageBox(NULL,L" Not Hooked", L"",0);
}
LRESULT CALLBACK MyMouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode <0)
{
CallNextHookEx(MyHook,nCode,wParam,lParam);
return 0;
}
if(wParam == WM_LBUTTONDOWN || wParam == WM_NCLBUTTONDOWN)
{
MessageBox(NULL,_T("OK"),_T("Test"),MB_OK);
PostMessage(hWndApp,WM_LBUTTONDOWN,0,0);
}
return CallNextHookEx(MyHook,nCode,wParam,lParam);
}
But in my app, when I use the function Hook(), it doesn't work at all. Did I do anything wrong? Someone plz help me
|
|
|
|
|
You need to declare the HHOOK MyHook; in a shared data section.
So you need to first create a data section, declare the HHOOK in that data section and then make that section shared.
Look at my article at
http://www.codeproject.com/KB/DLL/ParkMouse.aspx[^]
« Superman »
|
|
|
|
|
I am getting set hexa decimal values as I/P from user into a CString.
I am tokenizing this and get separate hexa values in another CString.
I want to convert this single hexa value in CString to unsigned char.
How to do this?
Or can I get input in unsigned char itself and tokenize is possible?
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
rp_suman wrote: I want to convert this single hexa value in CString to unsigned char.
Use strtoul() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
rp_suman wrote: I am getting set hexa decimal values as I/P from user into a CString.
I am tokenizing this and get separate hexa values in another CString.
I want to convert this single hexa value in CString to unsigned char.
You already have the IP in number form so it should be easier for you to split it out byte by byte. Why to use CString in between?
Or if you are forced to do so then you can use functions like StringToAddress and AddressToString for converting ipaddress byte array from and to a string. Though not sure whether this will work with IP address in hex form.
Hope this helps!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
modified on Monday, June 2, 2008 11:59 PM
|
|
|
|
|
Hi Nibu thomas,
Thanks for the help,
The input is some MIDI command like "0x90 0x00 0x01"
The separator can be space or comma.
If I get the above command, how to assign them to unsigned char array except separators if possible without CString?
I will try strtol() once which David crow recommended.
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
rp_suman wrote: The input is some MIDI command like "0x90 0x00 0x01"
The separator can be space or comma.
Well then you've got to convert it to byte form!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks for help from everybody!!
strtoul() is working!!
Thanks & Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Suppose there are three classes Class A, Class B and Class C.
Class A
{
public:
//one virtual function
}
Class B
{
public:
//one virtual function
}
Class C:virtual public A, virtual public B
{
}
How many v-tables Class C has?
|
|
|
|
|
Only One.
Regards,
Paresh.
|
|
|
|
|
The point here is, when ever this class is inherited, a new virtual table is created for the derived class and if any of the virtual functions are overridden the function pointers in the new vtable will be overwritten with the new address which points to the new function implementation. Do keep in mind that for every class which implements/inherit virtual functions will have only 1 vtable per class.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
In a console app, I want to be able to test whether stdout and stderr are both printing to the screen. My output is messy unless I get it right (I'm printing to both stdout, and to stderr, and if they both happen to be the screen, I get two copies; I only want one copy on the screen).
A line like
<br />
if( stdout == stderr )<br />
always tests false under all the Windows compilers I've tried, so I get the duplication I'm trying to avoid.
Any ideas?
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
DQNOK wrote: A line like
if( stdout == stderr )
always tests false under all the Windows compilers I've tried, so I get the duplication I'm trying to avoid.
What about:
if (&stdout == &stderr) In any case, I would really expect them to not ever be *equal* even though they may resolve to the same location (i.e., screen).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: What about:
if (&stdout == &stderr)
That won't compile under Visual C++
The standard says that stdout and stderr are macros that evaluate to FILE pointer rvalues. Taking the address them seems suspicious from the outset...
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
DQNOK wrote: Any ideas?
Does GetStdHandle() help?
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Nibu babu thomas wrote: Does GetStdHandle() help?
I'll look into it. Thanks for the idea.
David
|
|
|
|
|
Nibu babu thomas wrote: Does GetStdHandle() help?
From reading the MSDN site, I thought it would; but it doesn't do what I thought.
HANDLE stderrHndl = GetStdHandle(STD_ERROR_HANDLE);
HANDLE stdoutHndl = GetStdHandle(STD_OUTPUT_HANDLE);
...
(very incomplete!)
vfprintf( stderr, msg, args );
if( stderrHndl == stdoutHndl )
goto logprint;
vfprintf( stdout, msg, args );
logprint:
Because the stderrHndl == stdoutHndl is always evaluating to FALSE, I'm still double printing to the console.
David
|
|
|
|