Click here to Skip to main content
15,917,473 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: new vs free and malloc vs delete Pin
Aescleal23-May-10 5:39
Aescleal23-May-10 5:39 
AnswerRe: new vs free and malloc vs delete Pin
John R. Shaw23-May-10 6:23
John R. Shaw23-May-10 6:23 
AnswerRe: new vs free and malloc vs delete Pin
MS_TJ23-May-10 19:52
MS_TJ23-May-10 19:52 
GeneralRe: new vs free and malloc vs delete Pin
Aescleal24-May-10 4:25
Aescleal24-May-10 4:25 
Questionopen txt file form web or ftp ? Pin
da_22-May-10 3:38
da_22-May-10 3:38 
AnswerRe: open txt file form web or ftp ? Pin
Richard MacCutchan22-May-10 4:28
mveRichard MacCutchan22-May-10 4:28 
AnswerRe: open txt file form web or ftp ? Pin
norish22-May-10 8:58
norish22-May-10 8:58 
AnswerRe: open txt file form web or ftp ? Pin
David Crow22-May-10 16:28
David Crow22-May-10 16:28 
GeneralRe: open txt file form web or ftp ? Pin
wangningyu23-May-10 5:43
wangningyu23-May-10 5:43 
AnswerRe: open txt file form web or ftp ? Pin
Hristo-Bojilov23-May-10 3:44
Hristo-Bojilov23-May-10 3:44 
GeneralRe: open txt file form web or ftp ? Pin
da_23-May-10 4:09
da_23-May-10 4:09 
GeneralRe: open txt file form web or ftp ? Pin
Hristo-Bojilov23-May-10 4:59
Hristo-Bojilov23-May-10 4:59 
QuestionRelease IGraphBuilder interface in directshow problem Pin
raj157622-May-10 0:25
raj157622-May-10 0:25 
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 

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.