|
Hello,
Thanks for suggestions.
I have set the environment variable in like:
name = VSCOMNTOOLS
path = C:\program files\Microsoft Visual Studio\common\MSDev98\bin
Regards,
Jokhan
|
|
|
|
|
Please bear with me on this post, I have never coded anything in any form of C++ but my boss has given me the task of putting something together that for various reasons requires a C++ application.
The Setup
I have a C# application that launches a background process, this process has to be coded in C++. Fom time to time the C# application will need to close the background process, for various reasons I cannot do a dirty shutdown (i.e. just kill the process). So I am looking for a way of getting the C# app to make the C++ application shutdown cleanly (i.e. process some code before existing).
After doing a far bit of reading I have come across something called CEvent which I understand as being an event that can be fired by external process and caught with the C++ application.
The problem is that although I can easily hold my own in C# I havent got a clue when it comes to C++ so can anybody firstly tell me if I am on the right track, and if so can you point me in the direction of some basic tutorials.
Thanks in advance
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
The CMutex sync object works among process. I can be helpfull.
|
|
|
|
|
The sun rises with the speed of a cunning fox
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Here are some, but not all, options:
You first need to determine how the other program will be able to respond to the request to shutdown.
1. Event: If you want to watch for an event, then you must have a WaitForSingleObject, WaitForMultipleObjects, etc. call in your C++ program. You can code in a periodic check where you can try to wait for the object for a very brief time, like 50 milliseconds or less. If it is already signaled, then you can exit the C++ program, if you get TIMEOUT, then the event was not already signaled by the C# program.
2. You might also be able to use PostThreadMessage if you had some way to determine what the main thread identifier of the C++ progrma was, then you could watch for a registered window message in the C++ progrma and terminate, or else some other message of your choosing, use the MsgWaitForMultipleObjects to get the message.
3. If the C++ program has a window and you can determine the window handle, you can then just post a WM_CLOSE to the C++ program's main window.
4. If the C++ program has a window and you can NOT determine the window handle, you can always try a SendMessage with a registered window message that the C++ program is watching for.
|
|
|
|
|
Thanks for the reply.
After much reading, I have opted to create an event and then sit on WaitForSingleObject(...) this works something like this :
...
HANDLE hEvent = CreateEvent(NULL, true, false, "EventEngine 10062004-MICRG-4546-9DD2-F0868C319D02");
ResetEvent(hEvent);
WaitForSingleObject(hEvent, INFINITE);
...
I think this will work so all I need to work out now is how to get C# to set the event, fortunately this is more comfortable ground for me
Why o why cant I start my C++ jaunt with a nice and simple Hello World application
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
One thing I see here, is that I would not use the '-' or the spaces in your event name, just to be safe. It is good to use the GUID like you did, but I would collapse the name down to just the primary characters, like this:
"EventEngine10062004MICRG45469DD2F0868C319D02"
Also, your reset even is safe, as long as your C# app has not actually intentionally set it, in which case your C++ program will NEVER exit.
I generally use two events myself.
I use one like you did here, to signal the 'worker app' to exit, but I also use a second one that the 'master app' will wait for after it has started the worker app, to KNOW that the worker app has started. This blocks the starter app from inadvertently setting the 'kill' event before the worker app has started.
The master app does not wait infinite, it waits a certain amount of 'reasonable time' like 3 minutes, for the worker app to signal the started event, and if not seen in that time, you can assume the worker app did not start correctly.
Just something to keep in mind when you start wondering why your main app never shuts down...
|
|
|
|
|
MrEyes wrote:
Why o why cant I start my C++ jaunt with a nice and simple Hello World app
You can. Just have the program say "Hello world" in response to a CEvent fired by a C# program and you are there!!
Good luck.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Hi,
I have a dialog based application. It uses connection oriented Windows Sockets. My application is not responding or responding very latter to the user interface messages like mouse and keybard input; When the network data traffic producing high amount of Socket messages like FD_READ.
How can I solve this. Is there a short method to filter and process mouse and keyboard messages before processing socket's FD_READ message.
Thanks and best regards.
|
|
|
|
|
It sounds like you might have the application waiting in socket read.
Maybe putting the read in a worker thread would sort your problem ? I've done this before and it worked fine.
Elaine
The tigress is here
|
|
|
|
|
Put your socket read code etal into a worker thread. This will free up the main thread to do all the standard message handling for keyboard, mouse etc.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Willaims (Little Britain)
|
|
|
|
|
Thank a lot for your response Mr Trollslayer and Mr Antony M Kancidrowski,
My socket routines are non blocking and fully event driven. I am using WinSock APIs. The socket reader routine is event driven and do not blocks application when data is not received. When FD_READ message receives it reads available data's and then returns.
The worker thread is good solution but I have to handle up to 1024 server connections. More than one server connection and data receiving process may require high amount of system resources with this solution.
The problem is that; I want to capture mouse and keyboard messages before FD_READ message handling.
Thanks anmd best regards
Erkan Ermis
|
|
|
|
|
Or in another word, Can I replace my mouse and keyboard messages on the top of the application message que. I heard that it is possible but I can not see a sample code up to now.
Thanks and best regards.
Erkan Ermis
|
|
|
|
|
Hi,
I have a CEdit derived class I want to use for all my edit buttons in a dialog (lets call it MyCEditBase).
I want to use a tool tip for each edit that is derived from MyCEditBase.
I added the definition
CToolTipCtrl m_wndToolTip;
to MyCEditBase header file.
Now I created and
I'm trying to use a tool tip for a CEdit control with the following code:
m_wndToolTip.Create(this);
m_wndToolTip.Activate(m_EnableToolTip);
m_ToolTipText = "Edit Button Text";
m_wndToolTip.AddTool(this, m_ToolTipText);
Now to show the tool tip I have to override PreTranslateMessage but this is NEVER CALLED!!!
Then I tried to catch all ouse messages in OnWndMsg and execute the following:
m_wndToolTip.RelayEvent(&msg);
with a msg I filled myself. This does not show a tool tip.
Thanks.
avivhal
|
|
|
|
|
i am working in vc++ paroject which is SDI interface now i want to convert it into MDI form(multiple dailog interface). what is the simplest way to do it on exixsting SDI project
auur_sunao
|
|
|
|
|
The easiest way would be to compare an empty SDI application with an empty MDI application. I know that OnInitInstance() will have a few differences. As far as the frame goes, CMDIFrameWnd will be used instead of CFrameWnd . The document will use CMultiDocTemplate instead of CSingleDocTemplate .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i am working on windows services as my semester project. can any body tell me plz, how to call an .exe or .dll file from a service.
one more thing that what event is triggered when system is locked. (when we press ctrl+alt+del) i have found a function from MSDN lockworkstation() but this is not gonna work. i want to launch an exe file when user is logged on or lock or unlock the system. looking forward for any good suggestion.
thank u.
Nadir Ali
Student Information Technology
National University of Sciences and Technology
Pakistan
|
|
|
|
|
Csharper99 wrote:
...how to call an .exe or .dll file from a service.
How about CreateProcess() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
If you only have to run on WindowsXP or later, you are in luck.
Your service, after registering its service control handler function, should receive a control event of SERVICE_CONTROL_SESSIONCHANGE. This will pass a data structure with the information about what happened: log on, log off, session locked, etc.
From MSDN:"A HandlerEx function is an application-defined callback function used with the RegisterServiceCtrlHandlerEx function. A service program can use it as the control handler function of a particular service.
The LPHANDLER_FUNCTION_EX type defines a pointer to this function. HandlerEx is a placeholder for the application-defined name.
This function supersedes the Handler control handler function used with the RegisterServiceCtrlHandler function. A service can use either control handler, but the new control handler supports user-defined context data and additional extended control codes."
Also see this:"WTSSESSION_NOTIFICATION
The WTSSESSION_NOTIFICATION structure provides information about the session change notification. A service receives this structure in its HandlerEx function in response to a session change event."
Ticking away the moments that make up a dull day, I friter and waster the hours in an offhand way...
|
|
|
|
|
I like to change an ItemMenuBitmap with the CMenu::SetMenuItemBitmaps() function.
I have problem to display the correct bitmap. Usually a dot bitmap is displayed ( may be is the default bitmap of MFC ).
Below is the used code.
CBitmap bitMap ;
bitMap .LoadBitmap(IDB_BITMAP);
pPopup->SetMenuItemBitmaps(ID_MENU_ITEM1,
MF_BYCOMMAND,&bitMap, &bitMap);
|
|
|
|
|
Dont declare bitMap variable local . If you declare it out of the function that you wrote this code it work safe .
I wrote this code and work very well :
CBitmap m_CheckBitmap,m_UnCheckBitmap;
OnButton1()
{
ASSERT(m_CheckBitmap.LoadBitmap(IDB_BITMAP1));
// Associate bitmaps with the "Test" menu item.
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
(submenu->SetMenuItemBitmaps(ID_A_B, MF_BYCOMMAND,
&m_CheckBitmap, &m_CheckBitmap));
}
|
|
|
|
|
I like to change an ItemMenuBitmap with the CMenu::SetMenuItemBitmaps() function.
I have problem to display the correct bitmap. Usually a dot bitmap is displayed ( may be is the default bitmap of MFC ).
Below is the used code.
CBitmap bitMap ;
breadthBitMap.LoadBitmap(IDB_BITMAP);
pPopup->SetMenuItemBitmaps(ID_MENU_ITEM1,
MF_BYCOMMAND,&bitMap, &bitMap);
|
|
|
|
|
hey, guys
As we know that a commonly used PDF file maybe contains both the vector elements and raster elements.
If I want to transfer all of vetor elements to raster then what will I do?
I think that some API functions is neccessary, so who can show me them.
thanks all
|
|
|
|
|
|
You have to use a RIP (raster image processor).. There are several around... some cheap, some expensive.. some freeware. Have a look for an application called GhostScript... that'll do what you wnat to do.
|
|
|
|