简体   繁体   中英

Ensuring Windows Mobile application is not running - From a desktop app

I have a windows mobile 5.0 application (smartphone) that contains a flat data file (CSV), which contains a header row (two doubles), and a list of entries (two doubles, DateTime, and a string).

Occasionally, I need to "sync" the mobile application with a desktop application. The desktop application should read the CSV from the mobile device, and replace it with a new CSV file, based on the contents of the old one.

This seems pretty easy via RAPI (I'm guessing), but I need to ensure that the mobile application is not running. Is there a way to do this?

Mutex? Remote Process Viewer like stuff? File locking?

Thanks for any help you have

Mike

For whatever reason, the built-in RAPI Functions don't have anything for checking running processes like the ToolHelp API's . With C you could create a set of custom functions in a device library that call the ToolHelp APIs and in turn are called through CeRapiInvoke (which is a generic catch-all entry point for custom RAPI functions). Unfortunately there's no simple mechanism to do this in managed code.

Just use a simple file locking mechanism for the file being read/updated.

Either rename the file before use or create a second 'lock' file which you can check for the existence of.

Just thought of an easy way.

Every 3 seconds the program is running, update a registry key with the current datetime.

When I want to sync, check the mobile registry, check it again 5 seconds later. If the values changed, the program is still running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM