|
No
This function returns the module name of the creating process, not the dll I am executing in.
/Per
|
|
|
|
|
If you only have to run on Windows XP or Windows 2003 then look at this one GetModuleHandleEx using the GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS flag.
|
|
|
|
|
Are you sure?
http://www.mvps.org/vcfaq/sdk/7.htm
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes
"The Win32 API GetModuleFileName() is what you need. If you pass NULL as the module handle parameter, the function returns the path of the module that created the process (in other words - the application's exe file)."
|
|
|
|
|
Did you not read the last sentence for some reason?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
By default in MFC when you clicking button (CButton)
it sends message when button is up.
But I need that some of buttons on my dialog send message when button is down.
What I should change or add to button object or class ?
|
|
|
|
|
I suggest new class:
//// in header file
class CmyButton: public CButton
{
// Generated message map functions
//{{AFX_MSG(CmyButton)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//// in cpp file
BEGIN_MESSAGE_MAP(CmyButton, CButton)
//{{AFX_MSG_MAP(CmyButton)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CmyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("You click on button");
}
|
|
|
|
|
|
Please help,
How to invork the Internet Explorer with assigned url address?
I want to open the Internet Explorer with "www.yahoo.com" from my MFC project. The WinExec("iexplorer.exe", SW_SHOW) run the iexplorer.exe but with the default url address.
Thanks
|
|
|
|
|
|
Thanks! you're live saver.
|
|
|
|
|
Instead of Using WinExec use ShellExecute
here is small code snippet to Invoke the Yahoo.com from ShellExecute
::ShellExecute(NULL,"open","IExplorer.exe","http:////www.yahoo.com",NULL,SW_SHOW);
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I'm having some trouble making a thread I have exit nicely. The thread function looks like:
UINT tBeginCommunication (LPVOID pParam) {<br />
t_commPackage * commPackage = (t_commPackage*) pParam;<br />
while (commPackage->cmdStopThread) {<br />
... do thread work here ...<br />
}<br />
commPackage->haveStoppedThread = true;<br />
AfxEndThread(0, false);<br />
return 0;<br />
}
When I want to stop the thread, I have this:
m_serialPortData->cmdStopThread = true;<br />
while (!(m_serialPortData->haveStoppedThread));
It signals to stop the thread, and waits until the thread has stopped.
The problem is that the while loop in the controlling function is never exited, it hammers the CPU and therefore the OS, I need to end the process via Task Manager to get back control. The data is not deleted because of the false argument in the AfxEndThread call so the main function has a chance to read it in the while.
I know I must be missing some thread nuance everyone else knows so please let me know what I'm not doing right. Thanks in advance, Nate.
|
|
|
|
|
Instead of looping over a variable, loop over until you get a signal that says you are done. Something like
while (1)
{
signalledObject = WaitForMultipleObjects(...);
if (signalledObject = THREAD_QUIT)
break;
// Do your job
}
Regards
Senthil
My Blog
|
|
|
|
|
See here for tips on how to properly shut down a thread.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks, that helped a lot. I looked at that page and it showed me better ways of starting and ending the thread nicely. I wanted to use a timeout somehow before I knew about the event handles and signals so this solution works out very nicely. Deriving my class from CWinThread would have been overkill because I don't need that much control but knowing I can do that is good to know. I ended up making 3 handles to signals, one to signal a good start from the thread to the main app, one to signal from the main app to the thread to stop, and one last signal to tell the main app the thread finished and it works nicely. Thanks again for the excellent link, Nate.
|
|
|
|
|
Dear Friends,
I want to write an application which monitors all opened TCP/UDP ports on the local computer. Also i want to map those ports to owning applications, in order to determine which process has opened which port. There is an IP Helper API function GetTCPTable() , but it does not tell about the process. In Windows XP there is an undocumented API AllocateAndGetTCPExTableFromStack() which suits my needs. But i also want to support Win2K Operating system.
Please tell me is there any API which can helps me or any suggestion.
Imtiaz
|
|
|
|
|
hi,
how to load an image in the mainframe window's client area in a MDI application.
thanks
Cool Ju
|
|
|
|
|
|
|
Hi
I am working with FormView in SDI VC++ application. On my CForm view, I have many graphs and data displayed on it. I have to save the entire contents that are displayed on the CFormView as it is into .jpg or a .bmp file. Can any one suggest a method to do this.
Thanks
Madhavi
|
|
|
|
|
Draw your graphs and data onto a memory DC. That memory DC has an HBITMAP that can be saved to a file, there are articles on this site that explain how. You can then also BitBlt that memory DC to a control on your form for display.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I have some buttons and list controls on the view. I should be able to save all that is displayed on the form view to bmp or jpeg file, in order words the bmp or jpeg file should just be a snaposhot/printscreen of the CFormView. By using memdc, I can just save the drawings. Can you please suggest a method to do this.
|
|
|
|
|
Thanks for the suggestion.
By using memdc, I can only save all that is drawn using the DC.I have some buttons and list controls on the view. I should be able to save all that is displayed including the controls on the form view to bmp or jpeg file, in order words the bmp or jpeg file should just be a snaposhot/printscreen of the CFormView. Can you please suggest a method to do this.
|
|
|
|
|
Search this site for "Screen capture", there are many articles that cover the topic.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|