Windows Mobile 中启动外部应用程序

Windows Mobile下面Java一直没有比较好的模拟器,用了一段时间的JMM最新版,觉得不错,但是有些程序还是不能运行,就去下了个JBed,但是在JBed中安装程序时会搜索卡,感觉比较费时,用Resco Explorer用JBed带参数打开时,又安装不了,因为需要加额外的参数-ginstall,Resco Explorer不支持。

另外一种方法就是把 .jar 文件的关联改到JBed,不过平时主要用的JMM,不想改掉关联,所以想着写个程序,作为代理,在Resco Explorer里把 .jar 文件的路径传给这个代理,再通过这个程序带参数启动 JBed 来安装。

要做到这些,就需要在这个代理中启动外部应用程序,第一次写Windows Mobile下面的程序,不过都是微软一家人,也不是麻烦,在Google上找了资料,发现可以用 ShellExecuteEx 来启动外部应用程序,然后就开写了。

程序的主要代码就一段,功能就是接受参数,启动 JBed。

wchar_t* param;
param = (wchar_t*) LocalAlloc(LPTR, 255);
wsprintf(param, _T("-ginstall \"file:\\%s\""), lpCmdLine);
SHELLEXECUTEINFO execInfo;
ZeroMemory(&execInfo, sizeof(execInfo));
execInfo.cbSize = sizeof(execInfo);
execInfo.lpFile = _T("\\Storage Card\\J\\jbed.exe");
execInfo.lpParameters = param;
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
execInfo.lpVerb = _T("open");
ShellExecuteEx(&execInfo);

因为觉得用 .NET 的话,程序的启动速度太慢,所以就用了 C++ 来写。

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>