Article ID: 241531
Article Last Modified on 8/19/2005
APPLIES TO
- Microsoft eMbedded Visual Basic 3.0
- Microsoft Office Keyboard
This article was previously published under Q241531
SUMMARY
This article demonstrates how to create a simple UI-less DLL with eMbedded Visual C++ (eVC) and call that DLL from an eMbedded Visual Basic (eVB) application.
For illustrative purposes, the CreateProcess API function is wrapped for use by a eVB application targeting a Pocket PC device. The same process can be used for other devices supported by both eVC and eVB, as well as with the previous versions of the Windows CE development tools (the Windows CE Toolkit for Visual Basic 6.0 and the Windows CE Toolkit for Visual C++ 6.0).
MORE INFORMATION
Step-by-Step Example
How to Build the UI-less EVC DLL
- Launch Microsoft eMbedded Visual C++.
- From the File menu, select New.
- In the New dialog box, select the Projects tab and click on WCE Dynamic-Link Library.
- In the Project name text box, enter a project name, such as CProcess.
- Click OK to create the WCE DLL.
- In the WCE Dynamic-Link Library dialog box, select An empty Windows CE DLL project.
- Click Finish.
- Click the OK button of the New Project Information dialog box to create the project.
- From the File menu, choose New.
- In the New dialog box, select the Files tab, and then click on C++ Source File.
- In the File name text box, enter a file name, such as WinExecCE.
- Click the OK button.
- From the File menu, choose New.
- In the New dialog box, select the Files tab, and then click on Text File.
- In the File name text box, enter a file name, such as WinExecCE.def.
- Click the OK button.
Paste the following code into the WinExecCE.cpp file:
#include <windows.h> DWORD WINAPI WinExecCE (LPWSTR lpApplicationName, LPWSTR lpCommandLine) { DWORD dwError = NOERROR; PROCESS_INFORMATION pi = {0}; if (!CreateProcess (lpApplicationName, lpCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { dwError = GetLastError (); } else { if (pi.hProcess) CloseHandle (pi.hProcess); if (pi.hThread) CloseHandle (pi.hThread); } return dwError; }
Paste the following into the WinExecCE.def file:
EXPORTS WinExecCE
- From the WCE Configuration toolbar, select Pocket PC, Win32 (WCE ARM) Release, and Pocket PC (Default Device).
NOTE: If your Pocket PC device uses a different processor type, select that one instead. - Ensure that the Pocket PC device is connected to the desktop development computer.
- From the Build menu, select Rebuild All. The DLL is compiled and downloaded to the device.
- From the File menu, select Save Workspace, and then select Exit.
How to Build the eVB Application
- Launch eMbedded Visual Basic.
- Create a new Windows CE Pocket PC Project.
- Add command button Command1 to Form1.
Paste the following code into Form1:
Option Explicit Public Declare Function WinExecCE Lib "CProcess.DLL" ( _ ByVal lpApplicationName As String, _ lpCommandLine As String) As Long Private Sub Command1_Click() WinExecCE "Calc.exe", "" End Sub
- Ensure that the Pocket PC device is connected to the desktop development computer.
- Run the project.
- On the device, click on the command button to launch Calc.Exe.
Additional query words: eVB eVB6 shell wce
Keywords: kbhowto kbtoolkit KB241531