Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Release IGraphBuilder interface in directshow problem Pin
norish22-May-10 9:09
norish22-May-10 9:09 
QuestionChange Event of excel Pin
trioum21-May-10 23:55
trioum21-May-10 23:55 
GeneralRe: Change Event of excel Pin
norish22-May-10 9:14
norish22-May-10 9:14 
QuestionGDI+ JPEG to binary Pin
hxhl9521-May-10 17:30
hxhl9521-May-10 17:30 
AnswerRe: GDI+ JPEG to binary Pin
hxhl9521-May-10 18:27
hxhl9521-May-10 18:27 
GeneralRe: GDI+ JPEG to binary Pin
Alain Rist21-May-10 20:21
Alain Rist21-May-10 20:21 
GeneralRe: GDI+ JPEG to binary [modified] Pin
hxhl9522-May-10 6:34
hxhl9522-May-10 6:34 
QuestionAbout loadlibrary problem. [modified] Pin
wangningyu21-May-10 16:25
wangningyu21-May-10 16:25 
Hello everybody !

In my dll project,I export some functions, and I used them with the static library in main project,it's normal and have none errors.dll code like this:
// Golbal variables
unsigned char ParamBuffer[0x5c];
unsigned char SendBuffer[1024];
unsigned char RecvBuffer[1024];
CWaitDlg      *g_ProgressDlg;

int InitParams()
{
    // Initial the buffer before to write to the serialport.
    // On the side,or read the buffer from some files.
}

int SetSendBuffer(unsigned char *temp,int nLen)
{
    memcpy(ParamBuffer,temp,nLen);
    return 0;
}
int ShowDlg()
{
    // Show the mode progress windows ,and how many buffer was written.
}

int CreateDownThread()
{
    // Here is used a new thread to write the buffer to the serialport.
    ...
}


But I used it with dynamic library in the main project,the GUI is hang-up,and the buffer isn't written to the serialport,because I use the Portmon to catch the serial event.

the main project code like this:
// this is all global variable 
typedef BOOL (CALLBACK *MyTxtFormat)(char *,char *);	        // this function int other dll
typedef int (CALLBACK *MyShowLoadingDlg)(BOOL);
typedef int (CALLBACK *MySetSendBuffer)(unsigned char *,int nLen);
typedef int  (CALLBACK *MyCreateDownThread)();
typedef int (CALLBACK *MyInitialParam)();

static MyInitialParam		InitialParam;
static MyShowLoadingDlg		ShowLoadingDlg;						
static MySetSendBuffer		SetSendBuffer;
static MyCreateDownThread	CreateDownThread;

HINSTANCE			hCode;
HINSTANCE			hHardware;
MyTxtFormat			TxtFormat;

void CMainFrame::OnDownload()
{
	TCHAR	*szpBuffer = new TCHAR [8000];
	unsigned char szTemp[4096];

	BOOL		bRet = FALSE;
	CFile		pFile;
	DWORD		nActual = 0;

	memset(szpBuffer,255,8000);
	hCode=LoadLibrary("aaa.dll");
	TxtAAA=(MyTxtFormat)GetProcAddress(hCode,"TxtFormat");
	if (TxtToCode)
	{
		bRet = TxtFormat(strLDPath.GetBuffer(strLDPath.GetLength()),
			strBinPath.GetBuffer(strBinPath.GetLength()));
		if(!bRet)
		{
			MessageBox("TxtFormat error!");
			return;
		}
        
		// In the debug window,the szpBuffer is normal.
		if ( pFile.Open( _T(strBinPath),CFile::modeReadWrite | CFile::typeBinary, NULL ) )
		{
			nActual = pFile.Read(szpBuffer, 8000);
		}
	}
    
	// This is my dll,I used F10 to debug step info, that
	hHardware = LoadLibrary("bbb.dll");
	if(hHardware)
	{
		ShowLoadingDlg=(MyShowLoadingDlg)GetProcAddress(hHardware,"ShowLoadingDlg");
		if(ShowLoadingDlg == NULL)
		{
			MessageBox("ShowLoadingDlg Functioin Failed !");
			return;
		}
		InitialParam = (MyInitialParam)GetProcAddress(hHardware,"InitialParam");
		if(InitialParam == NULL)
		{
			MessageBox("InitialParam Functioin Failed !");
			return;
		}
		SetSendBuffer=(MySetSendBuffer)GetProcAddress(hHardware,"SetSendBuffer");
		if(SetPlcRam == NULL)
		{
			MessageBox("SetSendBuffer Functioin Failed !");
			return;
		}
		CreateDownThread = (MyCreateDownThread)GetProcAddress(hHardware,"CreateDownThread");
		if(CreateDownThread == NULL)
		{
			MessageBox("CreateDownThread Functioin Failed !");
			return;
		}
        
        // Here is to show the progress window.
	ShowLoadingDlg();
        InitialParam();
        SetSendBuffer(pBuffer,sizeof(pBuffer));
        CreateDownThread();
	}

	// This function is overed,but the GUI is all the same hang-up.
	pFile.Close();
	szpBuffer = NULL;
	delete szpBuffer;
	FreeLibrary(hHardware);
}


Generally,what causes of this error happend ? Smile | :)

modified on Friday, May 21, 2010 10:32 PM

AnswerRe: About loadlibrary problem. Pin
Aescleal21-May-10 19:33
Aescleal21-May-10 19:33 
AnswerRe: About loadlibrary problem. Pin
Richard MacCutchan21-May-10 21:35
mveRichard MacCutchan21-May-10 21:35 
AnswerRe: About loadlibrary problem. Pin
norish21-May-10 23:21
norish21-May-10 23:21 
QuestionHow to check if 2 network shares are the same folder. Pin
Green Fuze21-May-10 11:57
Green Fuze21-May-10 11:57 
QuestionRe: How to check if 2 network shares are the same folder. Pin
David Crow21-May-10 17:28
David Crow21-May-10 17:28 
AnswerRe: How to check if 2 network shares are the same folder. Pin
Green Fuze22-May-10 2:39
Green Fuze22-May-10 2:39 
QuestionPage layout in word Pin
mamcp21-May-10 10:08
mamcp21-May-10 10:08 
QuestionStatusBar? [modified] Pin
Software200721-May-10 9:34
Software200721-May-10 9:34 
AnswerRe: StatusBar? Pin
Richard MacCutchan21-May-10 21:39
mveRichard MacCutchan21-May-10 21:39 
QuestionIterator gives error Pin
b-rad31121-May-10 9:28
b-rad31121-May-10 9:28 
AnswerRe: Iterator gives error Pin
Nemanja Trifunovic21-May-10 9:53
Nemanja Trifunovic21-May-10 9:53 
GeneralRe: Iterator gives error Pin
b-rad31121-May-10 9:55
b-rad31121-May-10 9:55 
Questioneliminate zeros in vector of vectors [modified] Pin
b-rad31121-May-10 6:37
b-rad31121-May-10 6:37 
GeneralRe: eliminate zeros in vector of vectors Pin
Aescleal21-May-10 7:35
Aescleal21-May-10 7:35 
GeneralRe: eliminate zeros in vector of vectors Pin
b-rad31121-May-10 7:48
b-rad31121-May-10 7:48 
AnswerRe: eliminate zeros in vector of vectors Pin
Aescleal21-May-10 8:03
Aescleal21-May-10 8:03 
GeneralRe: eliminate zeros in vector of vectors Pin
b-rad31121-May-10 8:11
b-rad31121-May-10 8:11 

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.