Mr.Lucy

导航

动态链接库示例

 

#include <windows.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C"{ 
#endif
	
__declspec(dllexport) int  __cdecl myPuts(LPSTR lpszmsg)
{ 
	DWORD ccWriten;
	BOOL fret;
	HANDLE hhandle;
	hhandle = CreateFile("CONOUT.txt",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);		
	
	if (INVALID_HANDLE_VALUE == hhandle)
	{
		return EOF;
	}

	while(*lpszmsg != '\0')
	{
		fret = WriteConsole(hhandle,lpszmsg,1,&ccWriten,NULL);
		if (FALSE == fret ||(1 != ccWriten))
		{
			return EOF;
		}
		lpszmsg++;
	}
		
	return 1;
}		
		
#ifdef __cplusplus
}
#endif

 

 

posted on 2012-08-27 00:31  Mr.Lucy  阅读(205)  评论(0编辑  收藏  举报