Posts

Showing posts with the label Windows CE

Windows CE:Accessing a Stream Driver from an Application

#include "stdafx.h" #include <Windows.h> #include <WinBase.h> int _tmain(int argc, TCHAR *argv[], TCHAR *envp[]) {     HANDLE ret_device = ActivateDeviceEx(L"\\Drivers\\StreamTestDrv" , NULL,0, NULL);     if (ret_device == INVALID_HANDLE_VALUE)     {         printf("Invalid Handle\n");      }      else      {         printf("Valid Handle\n");      }     HANDLE fileptr = CreateFile(L"DRV1:",                                                      GENERIC_READ|GENERIC_WRITE,                                                      FILE_SHARE_READ | FILE_SHARE_WRITE...

Windows CE : Accessing Registry From your Driver

If you know a particular a registry key name then reading the value of the key can be done by using RegQueryValueEx function. Passing NULL as the fifth argument will return the length then you can allocate a bu er of that length and pass the pointer of it. Suppose I have added a key value pair in platform.reg as shown below: "Dll"="StreamTestDrv.dll" "Order"=dword:1 "Index"=dword:1 "Prefix"="DRV" "Flags"=dword:0010 ; User Mode: 0010 means DEVFLAGS_LOAD_AS_USERPROC "DisplayName"="User Mode Driver" In order to access the value of the key "DisplayName", Modify the DRV_Init function which was written in the previous post DWORD DRV_Init(LPCTSTR pContext, LPCVOID lpcContext) {     HKEY hkey;     ULONG ktype;     char kvalue[100];     DWORD klength = sizeof(kvalue);     RETAILMSG(TRUE, (TEXT("DRV Driver:DD_Init:%s\n"), pContext));     hkey = OpenDeviceKey(pConte...

Building a WinCE Runtime Image from command line

Step 1: Setting up the environment _WINCEROOT: This variable should point to the location where your windows ce folder is present SET WINCEROOT= C:\WINCE700 _OSDESIGNDIR: Should point to the OS Design Directory SET _OSDESIGNDIR = %_WINCEROOT_%\OSDESIGNS\Test _OSDESIGN: This variable should point to the OS Design xml file SET _OSDESIGN = %_WINCEROOT_%\OSDesigns\Test\Test\Test.xml Finally we have to set the _OSDESIGNCONFIG environmental variable SET _OSDESIGNCONFIG = Test X86  Release To generate a batch file which sets up the environment we have to use utility provided by Platform Builder "PBXmlUtils' and pass the above environmental variables you set as arguments to it. Eg; C:\Program Files (x86) \Microsoft Platform Builder \7.00\cepb\ideVS\PBXmlUtils.exe /getbuildenv /workspace "%_OSDESIGN%" /config "%_OSDESIGNCONFIG%" > Env.bat Now you have to open a command prompt and run this batch file to set the environment for build Step ...

Windows CE Simple Stream Driver

StreamTestDrv.cpp: #include "stdafx.h" #include "StreamTestDrv.h" #include <WinBase.h> #include <devload.h> #define SIZE_DRV 100 BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call,                                                  LPVOID lpReserved) {     switch(ul_reason_for_call)     {          case DLL_PROCESS_ATTACH:             RETAILMSG(1, (TEXT("DLLMAIN: Process Attach\n")));             break;         case DLL_THREAD_ATTACH:             RETAILMSG(TRUE,(TEXT("DLLMAIN: Thread ATTACH \n")));             break;         case DLL_THREAD_DETACH:             RETAILMSG(TRUE,(TEXT(" DLLMAIN: ...

Windows CE Telnet Server without authentication

Windows Embedded CE is provided with a Telnet server, that you can use on your target to access it from the network.This Telnet service can work in two diff erent modes: 1. Without Authentication: Anybody connecting to the Telnet have access to the target. 2. With Authentication Enable : Only trusted user with password have access to the target. In order to enable Telnet Server, in your OS Design, From the Catalog Item View Tab, Core OS -> Windows Embedded Compact -> Communication Services and Networking -> Servers-> Telnet Server Also you have to add additional registry keys in project.reg to enable the Telnet server as shown below: [HKEY_LOCAL_MACHINE\COMM\TELNETD] "IsEnabled"=dword:1 "UseAuthentication"=dword:0 Now in order to access the CE command line from your development Machine,Open Run and Type telnet <ip address>. Telnet is by default not enabled on Windows. In order to enable it, Open Control Panel -> Programs -...

Windows CE -- Setting/Clearing environmental variables for OS Design

An environmental variable contains information such as drive, path, or con figuration string. When you create an OS design, the IDE sets specific environmental variables based on the settings you choose for your design and run-time image.You can modify these environmental variable settings during the development process. You can set or clear environmental variables from: 1. A command prompt build window 2. A batch file 3. IDE To set/clear an environmental variable in the IDE: For example , to set the BSP_NOAUDIO environmental variable and exclude all audio components from the runtime image, we need to do the following: 1. In the IDE, select Project ->  Properties 2. On the left pane, expand the Con guration Properties node and click on Environment to bring up the Environmental Variables setting utility 3. To set an environmental variable for the OS Design, click on New and enter the Variable name and associated value, To set/clear environment...

Listing Loaded Devices in Windows CE

The APIs FindFirstDevice and FindNextDevice can be used to search for a device currently loaded in Windows CE 5.0 or above. These APIs are not available in versions prior to Windows CE 5.0. The following are the syntax: HANDLE FindFirstDevice(DeviceSearchType searchType,LPCVOID pvSearchParam, PDEVMGR_DEVICE_INFORMATION pdi); BOOL FindNextDevice(HANDLE h,, DEVMGR_DEVICE_INFORMATION pdi); If successful the FindFirstDevice returns a device handle which can be used for subsequent FineNextDevice.The FindNextDevice returns TRUE if there are more devices to nd otherwise returns FALSE #include <windows.h> #include "bldver.h" void EnumerateRunningDrivers( void ) {     #if CE_MAJOR_VER>4         HANDLE hDriver;         DeviceSearchType DeviceSearch = DeviceSearchByLegacyName;         DEVMGR_DEVICE_INFORMATION DeviceInfo;         DeviceInfo.dwSize = sizeof( DEVMGR_DEVICE_INFORMATIO...