|
Is this C++ .NET (never developed in the language)?
If this is C++ .NET then I would think this will work (you have to check the syntax, cause of
my lack in skills in programming C++ .NET)
graphics.DrawImage(pBitmap, 50, 300, 200, 80);
Greetings
Covean
|
|
|
|
|
"graphics.DrawImage()" doesn't show any bmp pic
|
|
|
|
|
kk_Kevin wrote: "graphics.DrawImage()" doesn't show any bmp pic
What does it return?
"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
|
|
|
|
|
I have a Win32 Service (written in C) that does a CreateProcess(). After that it waits for its own termination (the services').
I would like to monitor the subprocess such that the service gets notified when the subprocess terminates (for whatever reason).
I have an idea of doing this with events and WaitForMultipleObjects(), but somehow I'm missing the idea where to start.
Should the service create an event? Or should the subprocess do that? And how would that be notified to the service process so that it can wait for that event?
Help very much appreciated.
--
Christoph
|
|
|
|
|
If I understand you right, you start some processes within your service and then you wanna wait till the processes ends?
If so, then I would use the handle hProcess from the PROCESS_INFORMATION you get by calling CreateProcess
and then use WaitForSingleObject or WaitForMultipleObjects.
Greetings
Covean
|
|
|
|
|
Thanks for answering. I thought so as well. Could you supply some sample code?
Does the -->>> WaitForSingleObject(pi.hProcess,INFINITE);
hang in that function call? Then I would not reach the
code section after it which already contains :
I think I have to create some sort of event and put it in the hEvents[] array.
if( !CreateProcess( NULL,
execpath,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)
while(1) {
dWait=WaitForMultipleObjects(1,hEvents,FALSE,0);
if(dWait == WAIT_OBJECT_0)
break;
Sleep(1000);
}
cleanup:
if(pi.hProcess){
TerminateProcess(pi.hProcess,-1);
fprintf(logfile,"Subprocess %s terminated by service\n", execpath );
--
Christoph
modified on Wednesday, November 11, 2009 8:42 AM
|
|
|
|
|
A process handle acts as a kind of "event" and its fired if the process terminates, so you can add this handle to your hEvents array.
Does the -->>> WaitForSingleObject(pi.hProcess,INFINITE) hang in that function call?
Yes if you use INFINITE as time interval.
Here some code for you:
HANDLE hObjectsToWaitFor[2];
hObjectsToWaitFor[0] = hSomeEventHandle;
hObjectsToWaitFor[1] = pi.hProcess;
while(1)
{
dWait = WaitForMultipleObjects(2, &hObjectsToWaitFor, FALSE, 1000 );
switch(dWait)
{
case WAIT_OBJECT_0 + 0:
{
break;
}
case WAIT_OBJECT_0 + 1:
{
GetExitCodeProcess ( pi.hProcess, &procstat );
break;
}
default:
{
break;
}
}
}
[edit]
read the remarks section of WaitForMultipleObjects to see what kind of handles you also can wait for with.
(Examples: Event, Memory resource notification, Mutex, Process, Semaphore, Thread)
Greetings
Covean
|
|
|
|
|
Great! Many thanks. Just a minor drawback: When I stay in the while loop and the pi.hProcess has fired, the event sustains. Is there a way to reset the event automatically (or programmatically)?
--
Christoph
[edit]
I did the following (not sure whether it's correct):
while(1) {
dWait = WaitForMultipleObjects(2, &hEvents[0], FALSE, 1000 );
switch(dWait)
{
case WAIT_OBJECT_0 + 0:
{
goto cleanup;
break;
}
case WAIT_OBJECT_0 + 1:
{
timestamp(),fprintf(logfile,"Subprozess hat beendet mit exitcode %d, was tun?\n",
GetExitCodeProcess ( pi.hProcess, &procstat ));fflush(logfile);
ResetEvent(hEvents[1]);
hEvents[1]=NULL;
break;
}
default:
{
break;
}
}
}
modified on Wednesday, November 11, 2009 10:01 AM
|
|
|
|
|
You can try ResetEvent or change this event handle to an "empty" event you only create but never fire,
but I think the best way is to recreate the handle array without the process handle (be aware of that also the WAIT_OBJECT_0 + x value for all other events (after the process handle) changes if you remove this handle).
Here some pseudocode how I would solve this problem.
#define TIMEOUT_EVENT 0
struct WaitObject
{
HANDLE hWaitFor;
int nEventId;
}
int WaitForObjects(WaitObject[] waitObjects, bool bWaitAny, ....)
{
int nRetVal = 0;
int nLoop = 0;
HANDLE arrayWaitObjectHandles[waitObjects.Length];
for(; nLoop < waitObjects.Length; nLoop++)
arrayWaitObjectHandles[nLoop] = waitObjects[nLoop].hWaitFor;
nRetVal = WaitForMultipleObjects(waitObjects.Length, &arrayWaitObjectHandles, ...);
if(nRetVal == TIMEOUT)
return TIMEOUT_EVENT;
return waitObjects[nRetVal - WAIT_OBJECT_0].nEventId;
}
I know that this is not fully C (its too long ago^^) but I hope you understand the idea behind this,
just to build a function that waits for you and returns event ids (you assigned), so it will be easier
to remove the process handle from this array, because you waits for your assigned event ids.
I hope that helps.
PS: Viel Spass damit!
Greetings
Covean
|
|
|
|
|
Hi all,
I have changed my program Unicode based, from MBCS by changing in preprocessor. I have used all unicode supported syntex. Lastly it gives -
"cannot open file "mfc42ud.lib"
Can any one tell me why it is?
Thanks
|
|
|
|
|
|
Hi,
I have apply all this things. But it does not work. Can you tell me, which component will i install from visual studio cd.
|
|
|
|
|
Your original message statest that mfc42ud.lib could not be found. Have you istalled all the MFC libraries? Check the various library directories that are set in Visual Studio.
|
|
|
|
|
Did you run a search on your hard disk to see if mfc42ud.lib is actually present somewhere?
-Suhredayan
|
|
|
|
|
Hi,
Shaheen.India wrote: Can any one tell me why it is?
If I remember correctly... Visual Studio 6 did *not* install those Unicode MFC DLL's by default. When you install VS6 you need to navigate through the install choices and add the unicode DLL's. I would recommend getting your VS6 CD and modifying your installation.
Best Wishes,
-David Delaune
|
|
|
|
|
I am working on Excel Automation.
Application is MFC application without GUI.
All callbacks work perfectly in machine where office version is 2007 but same is not working in 2003.
When checking Excel.tli or tlh in both the machines, the size is different and AfterCalculate call back is missing in tli and tlh.
What needs to be added to application, to make it work for both versions.
This is how I imported:
#import "libid:00020813-0000-0000-C000-000000000046" auto_search no_dual_interfaces \
rename("DialogBox", "excelDialogBox") \
rename("RGB", "excelRGB") \
rename("DocumentProperties", "excelDocumentProperties") \
rename("SearchPath", "excelSearchPath") \
rename("CopyFile", "excelCopyFile") \
rename("ReplaceText", "excelReplaceText")
Please give me clue.
Regards,
KTTransfer.
|
|
|
|
|
try this one
#import \
".\MSO.DLL" \
rename("DocumentProperties","DocumentPropertiesXL") \
rename("RGB", "RGBXL")
#import \
".\VBE6EXT.OLB"
#import ".\EXCEL.EXE" \
rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") \
rename("DocumentProperties", "DocumentPropertiesXL") \
rename("ReplaceText","ReplaceTextXL") \
rename("CopyFile","CopyFileXL") \
exclude("IFont","IPicture") no_dual_interfaces
|
|
|
|
|
No its not working.
AfterCalculate event is introduced in office 2007.
So its not available in 2003.
But is there any way to get it by including any thing in application which works for both the versions.
If any idea.. .
Thanks in advance.
Regards,
KTTransfer.
|
|
|
|
|
ok it's working fine for me.But any way can you tell what you want to do?
|
|
|
|
|
I found this sample code "A Spell Checking Engine" but when I compiled this in VS C++ 2005 I got Lots of warnings and errors. Is there any updated version of this code which is compatible to VS C++ 2005?
|
|
|
|
|
napadaan wrote: I found this sample code "A Spell Checking Engine"
where did you find it?
napadaan wrote: I got Lots of warnings and errors
such as ?
napadaan wrote: Is there any updated version of this code which is compatible to VS C++ 2005?
why are you asking here ?
|
|
|
|
|
Hi,
Anyone know what is this dwExtraInfo in KBDLLHOOKSTRUCT.
thanks
Nitheesh.
Jose Jo Martin
http://www.simpletools.co.in
|
|
|
|
|
I'm not really sure about but I think it has only to do with the
function keybd_event where you can emulate a key-action and add
an extra 32 bit value for your own purposes.
Greetings
Covean
|
|
|
|
|
Hi,
i have an exe in a DVD and i placed the DVD named "A" in the Drive and invoked the exe from the DVD
and in the invoked exe which contains a Dialog with a button in it..and now i pressed the button it will throw a message box(im throwing message box from code) which tells to insert another DVD called "B" into the same drive....and now i removed the DVD and inserted the second DVD ("B")now ill press ok in the message box then what should happen is it should invoke the setupo.exe which is present in the second DVD "B".....but im getting a windows message like Wrong Volume is in the Drive.Please insert the DVD "A" into drive F: ..and it is not allowing to go further and the thing is this error comes only in windows XP machine only and everything works fine in windows 2003,2008 server....and one morething this message comes in windows 2003,2008 also but it comes only when i invoke taskmanager...and it doesn"t create any problem in that machines...
Please help me regarding the same...
modified on Wednesday, November 11, 2009 6:03 AM
|
|
|
|
|
HI all,
i m using help file of application like test.chm,
in my application i m using help button on each and every dialog or forms,
i m using shellexecute function to open the chm file,that is exist on location where exe of application present.
i want when i click on help button from any dialog or form than the chm file open with corresponding page of CHM file.
please tell me how can i do this,
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|