February 22, 2019
Hot Topics:

How the DesktopRapiInvoker Application Transfers the File

  • January 19, 2005
  • By Nancy Nicolaisen
  • Send Email »
  • More Articles »

Now, you open a file on the CE device, in this case using the Unicode string MyHTMLViewerText as the file name. You open for both reading and writing, allow shared reading, pass a NULL placeholder for the unused security attributes parameter, set the CREATE_ALWAYS flag that creates the file if it doesn't exist or opens an existing file, clears all attributes, and zeroes the file length, sets default file attributes, and passes a NULL placeholder for the unused template handle parameter.

//open a CE side file
HANDLE hFile = CeCreateFile (L"MyHTMLViewerText",
                             GENERIC_READ | GENERIC_WRITE,
                             FILE_SHARE_READ, NULL, CREATE_ALWAYS,
                             FILE_ATTRIBUTE_NORMAL, NULL);

Next, you copy the file data from the buffer on the desktop to the CE side. You don't do any error checking in this example, but in practice, you'd want to check to see that dwBytesWritten and dwFileSize were equal after the call, and take some remedial action otherwise.

//copy from the desktop to the CE device
DWORD dwBytesWritten;
CeWriteFile( hFile, (LPCVOID)pbFileBuff,
             dwFileSize,    &dwBytesWritten, NULL);

Finally, you close the remote file, close the desktop file, and uninitialize the RAPI subsystem.

   //close both files
   CeCloseHandle( hFile );

   //uninit rapi


Summing Up and Looking Ahead

There are two or three things that are always worth keeping in mind when you undertake a mixed-platform CE application:

  • Make sure you keep a careful eye on string data and scrupulously ensure the use of the Unicode format for any displayable text on the CE device.
  • Be aware that serial CE connections can be very slow.
  • Assume that you will run into low memory and low storage situations. Program defensively and leave yourself a graceful bailout strategy if you get squeezed.

In the next lesson, you'll explore the mechanics of launching an HTML viewer on the CE device.

About the Author

Nancy Nicolaisen is a software engineer who has designed and implemented highly modular Windows CE products that include features such as full remote diagnostics, CE-side data compression, dynamically constructed user interface, automatic screen size detection, and entry time data validation.

In addition to writing for Developer.com, she has written several books, including Making Win 32 Applications Mobile.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date