Click here to Skip to main content
15,914,409 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get CDocument pointer in Dialog class Pin
Mark Salsbery9-Nov-08 6:21
Mark Salsbery9-Nov-08 6:21 
QuestionHow to detect whether a COM port is available or not ? Pin
brucewayn8-Nov-08 21:45
brucewayn8-Nov-08 21:45 
AnswerRe: How to detect whether a COM port is available or not ? Pin
Rolf Kristensen9-Nov-08 1:29
Rolf Kristensen9-Nov-08 1:29 
QuestionHow can I create a working thread in a MFC regular dll Pin
W.Kim 19878-Nov-08 20:51
W.Kim 19878-Nov-08 20:51 
AnswerRe: How can I create a working thread in a MFC regular dll Pin
Mark Salsbery9-Nov-08 6:30
Mark Salsbery9-Nov-08 6:30 
GeneralRe: How can I create a working thread in a MFC regular dll Pin
W.Kim 19879-Nov-08 14:07
W.Kim 19879-Nov-08 14:07 
GeneralRe: How can I create a working thread in a MFC regular dll Pin
Mark Salsbery9-Nov-08 14:10
Mark Salsbery9-Nov-08 14:10 
GeneralRe: How can I create a working thread in a MFC regular dll [modified] Pin
W.Kim 19879-Nov-08 18:04
W.Kim 19879-Nov-08 18:04 
there is no compiler errors,linker errors..
the dll loads successfully,and I can call the function in the dll too.

and here is the funtion in the dll:
UINT threadproc(LPVOID lparam)//the thread callback funtion
{
	::MessageBox(NULL,"call the function succeefully","info",MB_OK);
	return 0;
}
extern "C" void __declspec(dllexport) dllext()//the dll export function
{
::MessageBox(NULL,"call the function succeefully in dllext()","info",MB_OK);
CWinThread*pThread=AfxBeginThread(threadproc,NULL,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED ,NULL);
pThread->ResumeThread();
}

and here is the function in a normal MFC application:
void CMainFrame::OnBeginthread() 
{
	//when I click the menu context..the application frame will call this function
	typedef void (*Pdllfun)();
	HINSTANCE hdll=LoadLibrary("thread.dll");
	if(hdll==NULL)
		::MessageBox(NULL,"can not laod the dll","",MB_OK);
	Pdllfun pdllfun=NULL;
	pdllfun=(Pdllfun)::GetProcAddress(hdll,"dllext");
	if(pdllfun==NULL)
		::MessageBox(NULL,"can not laod the dll funion","",MB_OK);
	pdllfun();//call the dll function
	FreeLibrary(hdll);
	
}

if I do not call the pThread->ResumeThread() function which in the dll,everything will be ok.
but once I call the pThread->ResumeThread() function,the main application will crash.
and the errors it returns to me is:
0x00fd102d instruction references "0x00fd102d" memory can not be written


Never Change My Goal!

modified on Monday, November 10, 2008 3:27 AM

GeneralRe: How can I create a working thread in a MFC regular dll Pin
Iain Clarke, Warrior Programmer9-Nov-08 22:25
Iain Clarke, Warrior Programmer9-Nov-08 22:25 
GeneralRe: How can I create a working thread in a MFC regular dll Pin
W.Kim 198710-Nov-08 3:06
W.Kim 198710-Nov-08 3:06 
GeneralRe: How can I create a working thread in a MFC regular dll Pin
Mark Salsbery10-Nov-08 4:53
Mark Salsbery10-Nov-08 4:53 
GeneralRe: How can I create a working thread in a MFC regular dll Pin
Mark Salsbery10-Nov-08 5:00
Mark Salsbery10-Nov-08 5:00 
QuestionPointer symbol position and constant member functions Pin
Christian Flutcher8-Nov-08 16:55
Christian Flutcher8-Nov-08 16:55 
AnswerRe: Pointer symbol position and constant member functions Pin
Saurabh.Garg8-Nov-08 18:55
Saurabh.Garg8-Nov-08 18:55 
GeneralRe: Pointer symbol position and constant member functions Pin
Christian Flutcher9-Nov-08 5:35
Christian Flutcher9-Nov-08 5:35 
AnswerRe: Pointer symbol position and constant member functions Pin
toxcct9-Nov-08 3:05
toxcct9-Nov-08 3:05 
GeneralRe: Pointer symbol position and constant member functions Pin
Christian Flutcher9-Nov-08 5:30
Christian Flutcher9-Nov-08 5:30 
AnswerRe: Pointer symbol position and constant member functions Pin
Iain Clarke, Warrior Programmer9-Nov-08 4:04
Iain Clarke, Warrior Programmer9-Nov-08 4:04 
GeneralRe: Pointer symbol position and constant member functions Pin
Christian Flutcher9-Nov-08 5:32
Christian Flutcher9-Nov-08 5:32 
QuestionHow to format like this 123,456,789.00? Pin
followait8-Nov-08 16:05
followait8-Nov-08 16:05 
AnswerRe: How to format like this 123,456,789.00? Pin
Saurabh.Garg8-Nov-08 18:57
Saurabh.Garg8-Nov-08 18:57 
GeneralRe: How to format like this 123,456,789.00? Pin
followait8-Nov-08 19:41
followait8-Nov-08 19:41 
AnswerRe: How to format like this 123,456,789.00? Pin
Randor 8-Nov-08 19:00
professional Randor 8-Nov-08 19:00 
AnswerRe: How to format like this 123,456,789.00? Pin
Hamid_RT8-Nov-08 20:22
Hamid_RT8-Nov-08 20:22 
QuestionWhy dosen't ShellExecute run some of commands? Pin
Joseph Marzbani8-Nov-08 9:26
Joseph Marzbani8-Nov-08 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.