Difference between revisions of "WinCE Programming Tips"
Sekelsenmat (talk | contribs) |
|||
Line 2: | Line 2: | ||
__TOC__ | __TOC__ | ||
{{Other Interfaces}} | {{Other Interfaces}} | ||
+ | |||
+ | == TIPS/ FAQ == | ||
+ | === Get Device ID === | ||
+ | Get and ID of your device useful for protect your application. | ||
+ | This work only on Windows Mobile 5.0 and Windows CE 5.1 | ||
+ | <delphi> | ||
+ | |||
+ | function GetDeviceUniqueID(AppData:LPCWSTR; cbApplictionData:Integer; dwDeviceIDVersion:Integer; var deviceIDOuput; var pcbDeviceIDOutput:DWORD):Integer; external 'coredll.dll' name 'GetDeviceUniqueID'; | ||
+ | |||
+ | function GetDeviceID: string; | ||
+ | var | ||
+ | AppData: array[0..19] of WideChar; | ||
+ | DeviceID : array[0..19] of Byte; | ||
+ | Count: DWORD; | ||
+ | s: string; | ||
+ | Res, i:Integer; | ||
+ | begin | ||
+ | //not sure about Unicode | ||
+ | AppData := Utf8Decode('MY_SIG');//any string you like | ||
+ | Count := SizeOf(DeviceID); | ||
+ | FillChar(DeviceID, Count, #0); | ||
+ | Res := GetDeviceUniqueID(AppData, SizeOF(AppData), 1, DeviceID, Count); | ||
+ | if Res = 0 then | ||
+ | begin | ||
+ | Result := ''; | ||
+ | for i := 0 to Count -1 do | ||
+ | begin | ||
+ | if (i > 0) and ((i mod 2) = 0) then | ||
+ | Result := Result + '-'; //add space make the string wrap in label | ||
+ | Result := Result + IntToHex(DeviceID[i], 2); | ||
+ | end; | ||
+ | end | ||
+ | else | ||
+ | Result := '';//error accord | ||
+ | // you can MD5 it with your string | ||
+ | // Result := MD5Print(MD5Buffer(DeviceID, Count)); | ||
+ | end; | ||
+ | </delphi> | ||
+ | Reference pages: | ||
+ | http://msdn2.microsoft.com/en-us/library/ms893522.aspx | ||
+ | http://peterfoot.net/RetrieveIMEIThroughTAPI.aspx | ||
+ | http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx | ||
+ | |||
+ | === Get Device Name === | ||
+ | Easy to get it from registry | ||
+ | |||
+ | <delphi> | ||
+ | function GetDeviceName: string; | ||
+ | var | ||
+ | aReg:TRegistry; | ||
+ | begin | ||
+ | aReg := TRegistry.Create(KEY_READ); | ||
+ | try | ||
+ | aReg.RootKey := HKEY_LOCAL_MACHINE; | ||
+ | aReg.OpenKey('Ident', False); | ||
+ | if aReg.ValueExists('Name') then | ||
+ | Result := aReg.ReadString('Name') | ||
+ | else | ||
+ | Result := 'GUEST'; | ||
+ | finally | ||
+ | aReg.Free; | ||
+ | end; | ||
+ | end; | ||
+ | </delphi> | ||
+ | |||
+ | === Show/Hide SIP Panel === | ||
+ | SIP: Software Input Panel button, it is a keyboard come with WinCE for touch screen devices. | ||
+ | |||
+ | <delphi> | ||
+ | const | ||
+ | //some of consts already found in Windows | ||
+ | SIPF_OFF = $00000000; | ||
+ | SIPF_ON = $00000001; | ||
+ | SIPF_DOCKED = $00000002; | ||
+ | SIPF_LOCKED = $00000004; | ||
+ | |||
+ | function SipShowIM(IPStatus:DWORD):Integer; stdcall; external 'coredll.dll' name 'SipShowIM'; | ||
+ | |||
+ | begin | ||
+ | SipShowIM(SIPF_ON) | ||
+ | end; | ||
+ | |||
+ | </delphi> | ||
+ | |||
+ | |||
+ | === Wakeup Device/ Power On === | ||
+ | If you like to make alarm application this function make your device power on, you need also make some sounds with it. | ||
+ | |||
+ | <delphi> | ||
+ | function SetSystemPowerState(psState: PWideChar; StateFlags: DWORD; Options : DWORD):DWORD; stdcall; external 'coredll.dll' name 'SetSystemPowerState'; | ||
+ | |||
+ | |||
+ | SetSystemPowerState(nil, POWER_STATE_ON, 0); | ||
+ | Application.BringToFront; | ||
+ | ShowWindow(Handle, SW_SHOW); | ||
+ | </delphi> | ||
+ | |||
+ | |||
==Using the Telephone API (TAPI)== | ==Using the Telephone API (TAPI)== | ||
Revision as of 14:45, 3 June 2008
This page is a under construction reference to in the development for the Windows CE platform, covering topics specific to it.
Other Interfaces
- Lazarus known issues (things that will never be fixed) - A list of interface compatibility issues
- Win32/64 Interface - The Windows API (formerly Win32 API) interface for Windows 95/98/Me/2000/XP/Vista/10, but not CE
- Windows CE Interface - For Pocket PC and Smartphones
- Carbon Interface - The Carbon 32 bit interface for macOS (deprecated; removed from macOS 10.15)
- Cocoa Interface - The Cocoa 64 bit interface for macOS
- Qt Interface - The Qt4 interface for Unixes, macOS, Windows, and Linux-based PDAs
- Qt5 Interface - The Qt5 interface for Unixes, macOS, Windows, and Linux-based PDAs
- GTK1 Interface - The gtk1 interface for Unixes, macOS (X11), Windows
- GTK2 Interface - The gtk2 interface for Unixes, macOS (X11), Windows
- GTK3 Interface - The gtk3 interface for Unixes, macOS (X11), Windows
- fpGUI Interface - Based on the fpGUI library, which is a cross-platform toolkit completely written in Object Pascal
- Custom Drawn Interface - A cross-platform LCL backend written completely in Object Pascal inside Lazarus. The Lazarus interface to Android.
Platform specific Tips
- Android Programming - For Android smartphones and tablets
- iPhone/iPod development - About using Objective Pascal to develop iOS applications
- FreeBSD Programming Tips - FreeBSD programming tips
- Linux Programming Tips - How to execute particular programming tasks in Linux
- macOS Programming Tips - Lazarus tips, useful tools, Unix commands, and more...
- WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
- Windows Programming Tips - Desktop Windows programming tips
Interface Development Articles
- Carbon interface internals - If you want to help improving the Carbon interface
- Windows CE Development Notes - For Pocket PC and Smartphones
- Adding a new interface - How to add a new widget set interface
- LCL Defines - Choosing the right options to recompile LCL
- LCL Internals - Some info about the inner workings of the LCL
- Cocoa Internals - Some info about the inner workings of the Cocoa widgetset
TIPS/ FAQ
Get Device ID
Get and ID of your device useful for protect your application. This work only on Windows Mobile 5.0 and Windows CE 5.1 <delphi>
function GetDeviceUniqueID(AppData:LPCWSTR; cbApplictionData:Integer; dwDeviceIDVersion:Integer; var deviceIDOuput; var pcbDeviceIDOutput:DWORD):Integer; external 'coredll.dll' name 'GetDeviceUniqueID';
function GetDeviceID: string; var
AppData: array[0..19] of WideChar; DeviceID : array[0..19] of Byte; Count: DWORD; s: string; Res, i:Integer;
begin
//not sure about Unicode AppData := Utf8Decode('MY_SIG');//any string you like Count := SizeOf(DeviceID); FillChar(DeviceID, Count, #0); Res := GetDeviceUniqueID(AppData, SizeOF(AppData), 1, DeviceID, Count); if Res = 0 then begin Result := ; for i := 0 to Count -1 do begin if (i > 0) and ((i mod 2) = 0) then Result := Result + '-'; //add space make the string wrap in label Result := Result + IntToHex(DeviceID[i], 2); end; end else Result := ;//error accord
// you can MD5 it with your string // Result := MD5Print(MD5Buffer(DeviceID, Count)); end; </delphi> Reference pages: http://msdn2.microsoft.com/en-us/library/ms893522.aspx http://peterfoot.net/RetrieveIMEIThroughTAPI.aspx http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx
Get Device Name
Easy to get it from registry
<delphi> function GetDeviceName: string; var
aReg:TRegistry;
begin
aReg := TRegistry.Create(KEY_READ); try aReg.RootKey := HKEY_LOCAL_MACHINE; aReg.OpenKey('Ident', False); if aReg.ValueExists('Name') then Result := aReg.ReadString('Name') else Result := 'GUEST'; finally aReg.Free; end;
end; </delphi>
Show/Hide SIP Panel
SIP: Software Input Panel button, it is a keyboard come with WinCE for touch screen devices.
<delphi> const
//some of consts already found in Windows SIPF_OFF = $00000000; SIPF_ON = $00000001; SIPF_DOCKED = $00000002; SIPF_LOCKED = $00000004;
function SipShowIM(IPStatus:DWORD):Integer; stdcall; external 'coredll.dll' name 'SipShowIM';
begin
SipShowIM(SIPF_ON)
end;
</delphi>
Wakeup Device/ Power On
If you like to make alarm application this function make your device power on, you need also make some sounds with it.
<delphi> function SetSystemPowerState(psState: PWideChar; StateFlags: DWORD; Options : DWORD):DWORD; stdcall; external 'coredll.dll' name 'SetSystemPowerState';
SetSystemPowerState(nil, POWER_STATE_ON, 0); Application.BringToFront; ShowWindow(Handle, SW_SHOW);
</delphi>
Using the Telephone API (TAPI)
TAPI reference pages:
http://msdn.microsoft.com/en-us/library/aa922068.aspx
http://www.developer.com/ws/pc/article.php/3496296
Sendings SMSes
Please write me