QueueDll.h in QueueDll.rar


by Windows Message Queue System Programming. This example is a DLL files, the sp...Original Link
    Sponsored links

			
#ifndef __QUEUEDLL_H__
#define __QUEUEDLL_H__

/*
* QueueDll.h  -> QueueDll.dll and QueueDll.lib
* 其他应用程序调用DLL有三种方法:
* (1) 在其他应用程序中加入QueueDll.h和QueueDll.lib文件进行编释,并把QueueDll.dll放到系统目录或当前目录。
*     应用时直接调用QueueDll.h中定义的函数就行。
*
* (2) 动态装入DLL.在其他应用程序中加入QueueDll.h,并把QueueDll.dll放到系统目录或当前目录。
*     在要调用的CPP文件中定义:
*			#include "QueueDll.h"
*			FUNCTION_TABLE    *Function;
*	使用示范:
*
*	装入DLL:
*  	HINSTANCE hHandle =LoadLibrary("QueueDll.dll");
* 
*	得到DLL的函数地址:
*	if ( hHandle )
*		Function = (FUNCTION_TABLE *)GetProcAddress (hHandle,"Function_Table");//Function_Table在DLL的CPP文件中定义:FUNCTION_TABLE    Function_Table;
*
*	测试DLL函数:
*	char buf[256];
*	memset(buf,0,sizeof(buf));
*	if ( Function )
*	{
*		创建队列:
*		BOOL CreateQueue = Function->RZGCreateQueue("MyQueue");
*		if ( !CreateQueue )
*		{
*			Function->RZGGetErrorStr(buf);
*			AfxMessageBox(buf);
*		}
*		else
*		{
*			向队列发送数据:
*			long n = Function->RZGSendQueue("MyQueue","zhangguan");
*
*			从队列中接收数据:
*			n = Function->RZGRecvQueue("MyQueue1",buf);
*			if ( n>0 )
*				AfxMessageBox(buf);
*			else
*			{
*				memset(buf,0,sizeof(buf));
*				Function->RGetQueueErrorStr(buf);
*				AfxMessageBox(buf);
*			}
*
*			删除队列:
*			Function->RZGDeleteQueue ("MyQueue");
*		}
*
*		释放DLL:
*		if ( hHandle )
*			FreeLibrary((HMODULE) hHandle);
*	 
* (3) 更简单的动态装入DLL.。
*	  要调用的函数为BOOL ZGCreateQueue( char *QueuePath );
*	  装载:HINSTANCE DllHandle=AfxLoadLibrary("QueueDll.dll");
*	  调用函数时做三个步骤:
*	  定义:BOOL (FAR * pZGCreateQueue) (char *); 
*	  得到函数地址:pZGCreateQueue =(BOOL (FAR *)(char *))GetProcAddress(DllHandle,"ZGCreateQueue"); 
*     调用:(pZGCreateQueue)(Param)
			

			...
			...
			... to be continued.

  This is a preview. To get the complete source file, 
  please click here to download the whole source code package.

			
			


Project Files

    Sponsored links
NameSizeDate
 QueueDll.def369.00 B11-01-01 09:08
 QueueDll.dsw539.00 B10-01-01 23:21
 QueueDll.h4.06 kB29-04-04 10:19
 QueueDll.dsp4.20 kB21-07-04 14:48
 QueueDll.cpp15.62 kB21-07-04 14:52
 QueueDllBak.cpp15.89 kB09-03-04 14:51
...

Related Items

    Sponsored links