|
Hi
I want to exit a running application.I have aquire the handle of running process but i am facing problem in closing this.
GetExitCodeProcess(hProcess,lpExitCode);//problem is here
TerminateProcess(hProcess,(UINT)lpExitCode);
Problem is this when i debug the application
"Unhandled exception at 0x7c81ab1f in DDEmailRecovery.exe: 0xC0000005: Access violation writing location 0x00000000."
|
|
|
|
|
Three things:
1) you didn't show us how lpExitCode declared. If it is smth like so;
DWORD *lpExitCode;
..then surely you will get the error. Declare like so instead;
DWORD dwExitCode;
GetExitCodeProcess(hProcess, &dwExitCode);
2) Had it worked, the wrong code would cry in
TerminateProcess(hProcess,(UINT)lpExitCode);
the 'correct' way would be
TerminateProcess(hProcess,(UINT)*lpExitCode);
Anyway.
3) Why calling GetExitCodeProcess before TerminateProcess??
And in general, TerminateProcess is a non-polite way of making a process exit. Actually the process will not 'exit' but be 'killed'.
-- modified at 10:35 Sunday 1st July, 2007
--
=====
Arman
|
|
|
|
|
In general you should't use TerminateProcess for this purpose (to cause another process to exit). The following is from MSDN:
The TerminateProcess function is used to unconditionally cause a process to exit. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
Calling ExitProcess is of no use to you as it kills the calling process.
TerminateProcess is mainly intended to be used by debuggers and system tools as a final solution when everything else has failed. If you want a process to shutdown ask it to. You may want to investigate the WM_CLOSE message and the GenerateConsoleCtrlEvent function (the latter for console applications).
Steve
|
|
|
|
|
call webbrowser.Navigate within a thread via post message to UI thread
i wan to navigate to a website using my webbrowser2 activeX i made. but i need to run threads to execute a webbrowser.Navigate. because webbrowser.Navigate can only be called by the main user interface thread, inorder to use it from within a browser, i would be using the postmessage command to the main thread with a custom message
heres my custom message
<br />
#define WM_GOWEBSITE (WM_APP + 1) <br />
here is the handler for WM_GOWEBSITE
<br />
void Dlg::On_WebsiteVisit() <br />
{<br />
m_webbrowser.Navigate("yahoo.com", NULL, NULL, NULL, NULL);<br />
return;<br />
<br />
}<br />
from within my thread, this is how i posted WM_GOWEBSITE
<br />
th_thread->PostMessage( WM_GOWEBSITE , 0,0);
after running debug , i am very sure the message got posted. But the problem now in the release version is that the page simply does not load.hovering my mouse over the activeX control i get the "half cursor,half hour glass" mouse cursor. the debug version is fine.
does anyone know what is going on?
can anyone please help me? thanks in advance!
|
|
|
|
|
I have MyApplication.exe without DLL file, built with MFC VC++version6. the application is generated by the wizard with no change to default settings. I would like to have the steps(the procedure): how to deploy this application to another computer where Visual C++6 (or visual studio) is not installed. It would be nice to have a simple example.
Thanks
sty
|
|
|
|
|
You just need to ensure that the MFC DLLs corresponding to your Visual C++ version are present in the target computer. For Visual C++ 6, it is MFC42.DLL (for MFC controls) and MSVCRT.DLL (Visual C++ Run-time Library). You could use Dependency Walker[^] to find out what else is your application dependent on.
PS: If you build your application by statically linking the MFC DLLs to it, then you don't necessarily need to have the above said files on the target computer.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
|
how to create manifest file for vista using mfc. pls help me. its urgent
|
|
|
|
|
On Vista you should use the VS2005. In VS2005, go to project properties by clicking "Project | Properties". In the property page go to "Configuration Properties | Linker | Manifest File", select "Generate Manifest" to "Yes". Then n the property page go to "Configuration Properties | Manifest Tool | Input and Output" select "Embed Manifest" to "Yes".
Hope this would help you.
Regards,
Paresh.
|
|
|
|
|
What is the needto use a manifest?
|
|
|
|
|
|
Cwebbrowser2 , cannot find the internet path
when i use this
m_webbrowser.Navigate("yahoo.com", NULL, NULL, NULL, NULL);
the program gave me the following error as shown in the picture
the upper message box is the first to come. followed by the lower messagebox
link to picture : [url]http://i8.tinypic.com/6byefcy.jpg[/url]
[IMG]http://i8.tinypic.com/6byefcy.jpg[/IMG]
it was working perfectly fine on my computer with compiler. When i brought it to another computer, this happened!
i tried redoing a new testing project and creating the webbrowser in the same manner and it was good
some information:
- using MFC
- created webbrowser2 by going to dialog editor, right click and select "insert activeX"
- disabled firewall on both computer
- both computers definitely have internet connection with IE 7
- m_webbrowser.Navigate runs in a worker thread
- the target website yahoo.com is definitely up. i checked with my firefox and IE browser
- no delay, noticed. which means webbrowser2 did not neven attempt to contact the site
can anyone please help?
|
|
|
|
|
i have narrowed the problem down to the navigate member function being run in a worker thread. however i cannot find the root cause to the problem
|
|
|
|
|
You need to pass a valid URL, such as http://yahoo.com
|
|
|
|
|
In my main scope i declare my pointer variables :
...
PSID ownerSid = NULL ;
PACL pDACL = NULL ;
ownerSid = GetOwnerSIDFromFile (path);
pDACL = GetDACLFromFile (path);
if(ownerSid) FreeSid(ownerSid);
if(pDACL) LocalFree(pDACL);
...
PSID and PACL still cause leakages altgough i try to release them. How can i handle that situation ?
Here are 2 functions i call :
PSID GetOwnerSIDFromFile (char* sFileOrFolderName)
{
DWORD dwRtnCode = 0;
PSID pSidOwner = NULL ;
HANDLE hFile;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
hFile = CreateFile(
sFileOrFolderName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
return NULL ;
AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pSidOwner) ;
if( !pSidOwner )
{
CloseHandle(hFile);
return NULL ;
}
dwRtnCode = GetSecurityInfo(
hFile,
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION,
&pSidOwner,
NULL,
NULL,
NULL,
NULL);
CloseHandle(hFile);
return pSidOwner ;
}
PACL GetDACLFromFile (char* sFileOrFolderName)
{
PACL pDACL = NULL ;
DWORD dwRtnCode = 0;
HANDLE hFile;
hFile = CreateFile(
sFileOrFolderName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
return NULL ;
pDACL = (PACL)LocalAlloc(LPTR,sizeof(PACL));
if( !pDACL )
return NULL ;
dwRtnCode = GetSecurityInfo(
hFile,
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&pDACL,
NULL,
NULL);
CloseHandle(hFile);
return pDACL ;
}
|
|
|
|
|
All,
I had a small task at hand of tracing out the contents of a packet(generally a binarry array) and was looking for a sample code on web to quickly do it. Couldn't find any, so wrote my own small function. I wanted to share this on this site. I am sure it would be helpful to many sorry souls like me .
I am already a registered member of this site. But I don't see any link on how to post a small code snippet.
Please adivse.
Samal
|
|
|
|
|
You're describing an article. A code snippet is useless without some text to describe what it does, and how, so you'd want to write a short article and use the article submission wizard to submit it, and the code.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
What are the best books on data structures starting separately for beginerr and advanced audience.
|
|
|
|
|
|
|
I'm running Visual Studio 2005 and I have a specific key set for toggling between full screen and windowed mode -- F10. The following is a section of my code that runs in a while loop and handles my messages.
while (!m_terminate)
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
m_terminate = true;
else if (msg.message == WM_KEYDOWN)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
Now, when I set a breakpoint at if (msg.message == WM_KEYDOWN), whenever I press a key in my program, Visual Studio will break at that line and allow me to debug into it. This works all the time except for when I press F10 (I have a few other keys for toggling things). When I press F10, my program will hang for a little while, and then just continue working as if nothing happened, and my breakpoint will not be hit. I'm curious as to why this is. Anyone have an idea?
I guess I should mention that I have declared MESSAGE msg; outside of the while loop.
MODIFIED: It seems like the F10 key is a special key that is handled differently from the others.
-- modified at 2:44 Sunday 1st July, 2007
|
|
|
|
|
Here's an addition to my problem. The F9 key is OK (VK_F9), but the F10 key is still not (VK_F10). VK_F9 = 0x78, VK_F10 = 0x79, as expected. Is there something in the details that I should know but that I've completely overlooked (such as VK_F10 being reserved for some kind of system use only, or whatnot)?
|
|
|
|
|
Only thing I can think of is that F10 is usually associated with "Step Over" when debugging. You could try re-mapping that command in the IDE to some other key.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
That's a thought that I had as well, but even when I compile it as release and run it directly from the executable without the debugger, it doesn't work.
|
|
|
|
|