📄 rencherrapi.cpp
字号:
// RencherRAPI.cpp: implementation of the CRencherRAPI class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "RapiTest.h"
#include "RencherRAPI.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRencherRAPI::CRencherRAPI() {}
CRencherRAPI::~CRencherRAPI() {}
void CRencherRAPI::InitializeSettings()
{
LPTSTR pPath = new TCHAR[MAX_PATH + 10];
GetSystemDirectory(pPath, MAX_PATH);
CString str(pPath);
str += "\\rapi.dll";
hInst = LoadLibrary(str);
if (hInst)
{
CeRapiInit = (FARPROC) GetProcAddress(hInst, "CeRapiInit");
CeRapiUninit = (FARPROC) GetProcAddress(hInst, "CeRapiUninit");
CeCreateFile = (pfnFunc0)GetProcAddress(hInst, "CeCreateFile");
CeWriteFile = (pfnFunc1)GetProcAddress(hInst, "CeWriteFile");
CeCloseHandle = (pfnFunc2)GetProcAddress(hInst, "CeCloseHandle");
CeFindFirstFile = (pfnFunc3)GetProcAddress(hInst, "CeFindFirstFile");
CeGetFileSize = (pfnFunc4)GetProcAddress(hInst, "CeGetFileSize");
CeReadFile = (pfnFunc5)GetProcAddress(hInst, "CeReadFile");
CeFindNextFile = (pfnFunc6)GetProcAddress(hInst, "CeFindNextFile");
CeCreateDirectory = (pfnFunc7)GetProcAddress(hInst, "CeCreateDirectory");
CeCreateProcess = (pfnFunc8)GetProcAddress(hInst, "CeCreateProcess");
CeGetSystemInfo = (pfnFunc9)GetProcAddress(hInst, "CeGetSystemInfo");
}
else
{
FreeLibrary(hInst);
}
}
#define BUFFER_SIZE 10240
void CRencherRAPI::CopyFiletoWinCE(CString strFileNamePC, CString strFileNamePPC)
{
CFile oldFile;
oldFile.Open(strFileNamePC, CFile::modeRead |CFile::typeBinary);
int iLen = oldFile.GetLength();
iLen = iLen / BUFFER_SIZE;
BSTR bstr = strFileNamePPC.AllocSysString();
SysFreeString(bstr);
CeRapiInit();
HANDLE h;
h = CeCreateFile(bstr, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
char cTemp[BUFFER_SIZE];
int n = BUFFER_SIZE;
DWORD nbytes;
CString s;
int iTotBytes = 0;
while(oldFile.Read(&cTemp, BUFFER_SIZE) >= 1)
{
CeWriteFile(h, &cTemp, (DWORD)n, &nbytes, NULL);
}
CeCloseHandle(h);
oldFile.Close();
CeRapiUninit();
}
CString CRencherRAPI::GetCStringFromFile(CString strFileName)
{
CString strOut;
LPSTR pText = NULL;
int iLen;
CFile f;
if (f.Open(strFileName, CFile::modeReadWrite))
{
iLen = f.GetLength();
pText = new char[iLen + 1];
f.Read(pText, iLen);
pText[iLen] = '\0';
CString str(pText);
strOut = str;
delete pText;
f.Close();
}
else
{
strOut = "Error";
}
return strOut;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -