#include "stdafx.h"
#include <Windows.h>
#define DIRNAME_LEN (MAX_PATH+2)
BOOL PrintStrings(HANDLE hOut,...)
{
DWORD msgLen,count;
LPCTSTR pMsg;
va_list pMsgList;
va_start(pMsgList,hOut);
while((pMsg=va_arg(pMsgList,LPCTSTR))!=NULL){
msgLen=_tcslen(pMsg);
if(!WriteConsole(hOut,pMsg,msgLen,&count,NULL)
&& !WriteFile(hOut,pMsg,msgLen * sizeof(TCHAR),
&count,NULL))
va_end(pMsgList);
return FALSE;
}
va_end(pMsgList);
return TRUE;
}
BOOL PrintMsg(HANDLE hOut,LPCTSTR pMsg){
return PrintStrings(hOut,pMsg,NULL);
}
int _tmain(int argc, LPTSTR argv[])
{
CHAR pwdBuffer[DIRNAME_LEN];
DWORD lenCurDir;
lenCurDir=GetCurrentDirectory(DIRNAME_LEN,pwdBuffer);
PrintMsg(GetStdHandle(STD_OUTPUT_HANDLE),pwdBuffer);
system("pause");
return 0;
}