Difference between revisions of "WinCE Programming Tips/ru"
m |
|||
Line 33: | Line 33: | ||
* http://hpcmonex.net/izemize.htm | * http://hpcmonex.net/izemize.htm | ||
+ | |||
+ | ==== Не тот процессор ==== | ||
+ | |||
+ | Возможно, на устройстве установлен не ARM, наиболее распространённый, а x86 или MIPS. | ||
+ | Тут уж ничего не поделаешь. | ||
+ | |||
+ | ==== Отсутствие функций из-за версии операционной системы ==== | ||
+ | |||
+ | Возможно, операционная система очень старая, и в ней просто нет функций, используемых Lazarus'ом. | ||
+ | |||
+ | === Получить ID устройства === | ||
+ | |||
+ | Идентификация устройства полезна для защиты вашей программы. | ||
+ | Работает только на windows mobile 5.1 и 5.2 | ||
+ | <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'); | ||
+ | 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> | ||
+ | |||
+ | Ссылки: | ||
+ | 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 | ||
+ | |||
+ | === Получить имя устройтсва === | ||
+ | Это легко стелать через реестр: | ||
+ | |||
+ | <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> | ||
+ | |||
+ | === Показать/спрятать SIP Panel === | ||
+ | Виртуальная клавиатура для сенсорных экранов(SIP: Software Input Panel button). | ||
+ | |||
+ | <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> |
Revision as of 18:53, 20 August 2010
Эта статья относится только к WinCE.
См. также: Multiplatform Programming Guide
│
English (en) │
русский (ru) │
На этой странице описано несколько приёмов работы с платформой WinCE.
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
Советы / ЧаВо
Приложение работает на эмуляторе, но не работает на устройстве
Когда приложение запущено на эмуляторе, всё нормально, однако на устройстве возникает ошибка типа:
Cannot find 'project1' (or one of its components).
'project1' (или один из компонентов) не найден.
Возможно, ошибка возникает, потому что:
Отсуствует aygshell.dll
Эта ошибка обычно указывает на отсутствие библиотеки на целевом устройстве, особенно если у вас приложение типа "Hello World". Часто это связано с библиотекой aygshell.dll, которая отсуствует на многих устройствах под управлением "голых" Windows CE - как правило, на устройствах под управлением Windows Mobile этой проблемы не возникает.
Эта проблема наблюдалась на считывателях штрих-кодов motorolla, работавших под WinCE 4.2 и 5.
Проблема решается распространением aygshell.dll вместе с программой(кажется, так делает gps-программа navitel).
Вот пара ссылок на темы форума freepascal.org, где обсуждаются проблемы с aygshell.dll(на английском):
- http://forum.lazarus.freepascal.org/index.php/topic,7161.0.html
- http://forum.lazarus.freepascal.org/index.php/topic,5524.0.html
А здесь(тоже на английском) изменения в версиях библиотеки aygshell.dll:
Не тот процессор
Возможно, на устройстве установлен не ARM, наиболее распространённый, а x86 или MIPS. Тут уж ничего не поделаешь.
Отсутствие функций из-за версии операционной системы
Возможно, операционная система очень старая, и в ней просто нет функций, используемых Lazarus'ом.
Получить ID устройства
Идентификация устройства полезна для защиты вашей программы. Работает только на windows mobile 5.1 и 5.2 <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'); 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>
Ссылки: 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
Получить имя устройтсва
Это легко стелать через реестр:
<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>
Показать/спрятать SIP Panel
Виртуальная клавиатура для сенсорных экранов(SIP: Software Input Panel button).
<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>