PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

transfer files between Pocket PC and PC using Visual C++

Using RAPI funcions, like CeCopyFile....

anyone can write a simple example?

I stuck on this... my code is :

HRESULT hr = CeRapiInit();
if (FAILED(hr))
{
CeRapiUninit();
AfxMessageBox("Cannot connect to the HHT.", MB_OK | MB_ICONSTOP | MB_TOPMOST);
return ;
}

CeCopyFile (L"a.cpp", L"a.cpp", FALSE);

DWORD lasterror= CeGetLastError( );

CeRapiUninit ();

.... but always get lasterror=2 ,what means ERROR_FILE_NOT_FOUND.... but file IS there...

Please help me...
Hi,

Rather than use RAPI I just include any files I want on the device as a resource, then copy from the resource into the device.

Code:

HRSRC hrInfo = FindResource(hInstance, MAKEINTRESOURCE(IDR_BIN2), TEXT("BIN") ); //RT_RCDATA ); // Raw data
if ( hrInfo == NULL )
{
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, (LPTSTR) &lpMsgBuf;, 0, NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}

HANDLE pData = LoadResource(hInstance, hrInfo);
DWORD dwLen = SizeofResource(hInstance, hrInfo);
// Open the file for reading
HANDLE hFile = CreateFile( TEXT("\\My Documents\\BG.RAW"), GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS | TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 0 );
if ( hFile != INVALID_HANDLE_VALUE )
{
DWORD dwWritten = 0;
WriteFile( hFile, (LPVOID)pData, dwLen, &dwWritten;, NULL );
CloseHandle( hFile );
}


That way I can just add files as needed during development, remeber to remove before deploying :)

Hope this helps.
Scata
Just read your post again, ignore the above, still recovering from last night..
:lol:
Scata
codepunk · 05 Oct 2002, 16:55 UTC — Needs path info
Try putting full path information for your params, e.g.

copy( "c:\\test.txt", "\\test.txt" )

That should do it.