simmgr.inc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2007 Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. { Declarations for tapi WinCE API, note than on WinCE simmgr functions originally
  11. based in coredll.dll
  12. SIM Manager is an API set that allows access to information stored on the SIM Card
  13. This port based on Windows Mobile 5 Smartphone Edition SDK
  14. contact S0vNark0m for more information [email protected] (en, ru)
  15. }
  16. {$ifdef read_interface}
  17. //*****************************************************************************
  18. // consts
  19. //*****************************************************************************
  20. const
  21. SIM_ERRORCLASS_SIM = $02; // Problem with the SIM
  22. SIM_ERRORCLASS_PASSWORD = $01; // Unspecified phone failure
  23. SIM_ERRORCLASS_STORAGE = $03; // Error relating to storage
  24. SIM_ERRORCLASS_NONE = $00; // Misc error
  25. FACILITY_SIM = $800;
  26. ERROR_BASE = Longword(SEVERITY_ERROR) shl 31 or Longword(FACILITY_SIM) shl 16; // C Macros conversion, internal def
  27. // Internal def = errclass shl 8
  28. MSE_ERRORCLASS_SIM = ERROR_BASE or Word(SIM_ERRORCLASS_SIM) shl 8;
  29. MSE_ERRORCLASS_PASSWORD = ERROR_BASE or Word(SIM_ERRORCLASS_PASSWORD) shl 8;
  30. MSE_ERRORCLASS_STORAGE = ERROR_BASE or Word(SIM_ERRORCLASS_STORAGE) shl 8;
  31. MSE_ERRERRORCLASS_NONE = ERROR_BASE or Word(SIM_ERRORCLASS_NONE) shl 8;
  32. // Error | Various errors
  33. SIM_E_SIMFAILURE = MSE_ERRORCLASS_SIM or $01; // SIM failure was detected
  34. SIM_E_SIMBUSY = MSE_ERRORCLASS_SIM or $02; // SIM is busy
  35. SIM_E_SIMWRONG = MSE_ERRORCLASS_SIM or $03; // Inorrect SIM was inserted
  36. SIM_E_NOSIMMSGSTORAGE = MSE_ERRORCLASS_SIM or $04; // SIM isn't capable of storing messages
  37. SIM_E_SIMTOOLKITBUSY = MSE_ERRORCLASS_SIM or $05; // SIM Application Toolkit is busy
  38. SIM_E_SIMDOWNLOADERROR = MSE_ERRORCLASS_SIM or $06; // SIM data download error
  39. SIM_E_SIMNOTINSERTED = MSE_ERRORCLASS_SIM or $07; // SIM isn't inserted into the phone
  40. SIM_E_PHSIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $20; // PH-SIM PIN is required to perform this operation
  41. SIM_E_PHFSIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $21; // PH-FSIM PIN is required to perform this operation
  42. SIM_E_PHFSIMPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $22; // PH-FSIM PUK is required to perform this operation
  43. SIM_E_SIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $23; // SIM PIN is required to perform this operation
  44. SIM_E_SIMPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $24; // SIM PUK is required to perform this operation
  45. SIM_E_INCORRECTPASSWORD = MSE_ERRORCLASS_PASSWORD or $25; // Incorrect password was supplied
  46. SIM_E_SIMPIN2REQUIRED = MSE_ERRORCLASS_PASSWORD or $26; // SIM PIN2 is required to perform this operation
  47. SIM_E_SIMPUK2REQUIRED = MSE_ERRORCLASS_PASSWORD or $27; // SIM PUK2 is required to perform this operation
  48. SIM_E_NETWKPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $28; // Network Personalization PIN is required to perform this operation
  49. SIM_E_NETWKPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $29; // Network Personalization PUK is required to perform this operation
  50. SIM_E_SUBSETPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2A; // Network Subset Personalization PIN is required to perform this operation
  51. SIM_E_SUBSETPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2B; // Network Subset Personalization PUK is required to perform this operation
  52. SIM_E_SVCPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2C; // Service Provider Personalization PIN is required to perform this operation
  53. SIM_E_SVCPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2D; // Service Provider Personalization PUK is required to perform this operation
  54. SIM_E_CORPPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2E; // Corporate Personalization PIN is required to perform this operation
  55. SIM_E_CORPPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2F; // Corporate Personalization PUK is required to perform this operation
  56. SIM_E_MEMORYFULL = MSE_ERRORCLASS_STORAGE or $40; // Storage memory is full
  57. SIM_E_INVALIDINDEX = MSE_ERRORCLASS_STORAGE or $41; // Invalid storage index was supplied
  58. SIM_E_NOTFOUND = MSE_ERRORCLASS_STORAGE or $42; // A requested storage entry was not found
  59. SIM_E_MEMORYFAILURE = MSE_ERRORCLASS_STORAGE or $43; // Storage memory failure
  60. SIM_E_SIMMSGSTORAGEFULL = MSE_ERRORCLASS_STORAGE or $44; // Message storage on the SIM is full
  61. SIM_E_EMPTYINDEX = MSE_ERRORCLASS_STORAGE or $45; // Storage location is empty
  62. SIM_E_NOTREADY = MSE_ERRERRORCLASS_NONE or $60; // SIM isn't yet ready to perform the requested operation
  63. SIM_E_SECURITYFAILURE = MSE_ERRERRORCLASS_NONE or $61; // SIM isn't yet ready to perform the requested operation
  64. SIM_E_BUFFERTOOSMALL = MSE_ERRERRORCLASS_NONE or $62; // Buffer too small
  65. SIM_E_NOTTEXTMESSAGE = MSE_ERRERRORCLASS_NONE or $63; // Requested SMS message is not a text message
  66. SIM_E_NOSIM = MSE_ERRERRORCLASS_NONE or $64; // Device doesn't have a SIM
  67. SIM_E_NETWORKERROR = MSE_ERRERRORCLASS_NONE or $65; // There was a network error
  68. SIM_E_MOBILEERROR = MSE_ERRERRORCLASS_NONE or $66; // Mobile error
  69. SIM_E_UNSUPPORTED = MSE_ERRERRORCLASS_NONE or $67; // The command is unsupported
  70. SIM_E_BADPARAM = MSE_ERRERRORCLASS_NONE or $68; // Bad parameter
  71. SIM_E_UNDETERMINED = MSE_ERRERRORCLASS_NONE or $69; // Undetermined error
  72. SIM_E_RADIONOTPRESENT = MSE_ERRERRORCLASS_NONE or $6A; // The Radio is not present
  73. SIM_E_RADIOOFF = MSE_ERRERRORCLASS_NONE or $6B; // The Radio is off
  74. // Callback | Various notifications that are passed to the callback
  75. SIM_NOTIFY_CARD_REMOVED = $100; // SIM card was removed; lpData is NULL
  76. SIM_NOTIFY_FILE_REFRESH = $101; // Files on the SIM were refreshed; lpData points to a SIMFILEREFRESH structure
  77. SIM_NOTIFY_MSG_STORED = $102; // A message was stored to the SIM; lpData points to a SIMMESSAGECHANGE structure
  78. SIM_NOTIFY_MSG_DELETED = $103; // A message was removed from the SIM; lpData points to a SIMMESSAGECHANGE structure
  79. SIM_NOTIFY_PBE_STORED = $104; // A phone book entry was stored to the SIM; lpData points to a SIMPBECHANGE structure
  80. SIM_NOTIFY_PBE_DELETED = $105; // A phone book entry was removed from the SIM; lpData points to a SIMPBECHANGE structure
  81. SIM_NOTIFY_MSG_RECEIVED = $106; // Class 2 SMS was sent directly to the SIM; lpData points to a SIMMESSAGECHANGE structure
  82. SIM_NOTIFY_RADIOOFF = $107; // The Radio has been turned off but AT interpreter is still on; lpData is NULL
  83. SIM_NOTIFY_RADIOON = $108; // The Radio is present and is now on; lpData is NULL
  84. SIM_NOTIFY_RADIOPRESENT = $109; // A Radio Module/Driver has been installed; lpData is points to a DWORD which is 0 if the radio is OFF and 1 if the radio is ON
  85. SIM_NOTIFY_RADIOREMOVED = $10A; // A Radio Module/Driver has been removed; lpData is NULL }
  86. // Parameter flags for SimInitialize
  87. SIM_INIT_NONE = $00000000; // Do not send any notifications
  88. SIM_INIT_SIMCARD_NOTIFICATIONS = $00000001; // Send SIM card related notifications
  89. // SIMPHONEBOOKENTRY
  90. SIM_PARAM_PBE_ADDRESS = $00000001; // lpszAddress field is valid
  91. SIM_PARAM_PBE_ADDRESS_TYPE = $00000002; // dwAddressType field is valid
  92. SIM_PARAM_PBE_NUMPLAN = $00000004; // dwNumPlan field is valid
  93. SIM_PARAM_PBE_TEXT = $00000008; // lpszText field is valid
  94. SIM_PARAM_PBE_ALL = $0000000f; // All fields are valid
  95. // SIMMESSAGE
  96. SIM_PARAM_MSG_ADDRESS = $00000001; // lpszAddress field is valid
  97. SIM_PARAM_MSG_ADDRESS_TYPE = $00000002; // dwAddressType field is valid
  98. SIM_PARAM_MSG_NUMPLAN = $00000004; // dwNumPlan field is valid
  99. SIM_PARAM_MSG_RECEIVE_TIME = $00000008; // stReceiveTime field is valid
  100. SIM_PARAM_MSG_HEADER = $00000010; // rgbHeader field is valid
  101. SIM_PARAM_MSG_HEADER_LENGTH = $00000020; // cbHdrLength field is valid
  102. SIM_PARAM_MSG_MESSAGE = $00000040; // lpszMessage field is valid
  103. SIM_PARAM_MSG_ALL = $0000007f; // All fields are valid
  104. // SIMCAPS }
  105. SIM_PARAM_CAPS_PBSTORAGES = $00000001; // dwPBStorages field is valid
  106. SIM_PARAM_CAPS_PBEMAXADDRESSLENGTH = $00000002; // dwPBEMaxAddressLength field is valid
  107. SIM_PARAM_CAPS_PBEMAXTEXTLENGTH = $00000004; // dwPBEMaxTextLength field is valid
  108. SIM_PARAM_CAPS_PBEMININDEX = $00000008; // dwMinPBIndex field is valid
  109. SIM_PARAM_CAPS_PBEMAXINDEX = $00000010; // dwMaxPBIndex field is valid
  110. SIM_PARAM_CAPS_LOCKFACILITIES = $00000020; // dwLockFacilities field is valid
  111. SIM_PARAM_CAPS_LOCKINGPWDLENGTH = $00000040; // dwNumLockingPwdLengths and rgLockingPwdLengths fields are valid
  112. SIM_PARAM_CAPS_READMSGSTORAGES = $00000080; // dwReadMsgStorages field is valid
  113. SIM_PARAM_CAPS_WRITEMSGSTORAGES = $00000100; // dwWriteMsgStorages field is valid
  114. SIM_PARAM_CAPS_ALL = $000001ff; // All fields are valid
  115. // SIMRECORDINFO
  116. SIM_PARAM_RECORDINFO_RECORDTYPE = $00000001; // dwRecordType field is valid
  117. SIM_PARAM_RECORDINFO_ITEMCOUNT = $00000002; // dwItemCount field is valid
  118. SIM_PARAM_RECORDINFO_SIZE = $00000004; // dwSize field is valid
  119. SIM_PARAM_RECORDINFO_ALL = $00000007; // All fields are valid
  120. // SIMFILEREFRESH }
  121. SIM_PARAM_FILEREFRESH_FLAGS = $00000001; // dwFlags field is valid
  122. SIM_PARAM_FILEREFRESH_FILECOUNT = $00000002; // dwFileCount field is valid
  123. SIM_PARAM_FILEREFRESH_FILEARRAY = $00000004; // rgdwAddress field is valid
  124. SIM_PARAM_FILEREFRESH_ALL = $00000007; // All fields are valid
  125. // Phonebook Storage | Phone book storage locations }
  126. SIM_PBSTORAGE_EMERGENCY = $00000001; // Emergency dial list
  127. SIM_PBSTORAGE_FIXEDDIALING = $00000002; // SIM fixed dialing list
  128. SIM_PBSTORAGE_LASTDIALING = $00000004; // SIM last dialing list
  129. SIM_PBSTORAGE_OWNNUMBERS = $00000008; // SIM ownnumbers lists
  130. SIM_PBSTORAGE_SIM = $00000010; // General SIM Storage
  131. SIM_NUMPBSTORAGES = 5; // Number of phonebook storages
  132. // SIM DevCaps | Device Capabilities }
  133. SIM_CAPSTYPE_PBENTRYLENGTH = $00000001; // Phonebook entry lengths
  134. SIM_CAPSTYPE_PBSTORELOCATIONS = $00000002; // Phonebook storage locations
  135. SIM_CAPSTYPE_LOCKFACILITIES = $00000004; // Lock facilities
  136. SIM_CAPSTYPE_PBINDEXRANGE = $00000008; // Valid phonebook entry indexes
  137. SIM_CAPSTYPE_LOCKINGPWDLENGTHS = $00000010; // Locking password lengths
  138. SIM_CAPSTYPE_MSGMEMORYLOCATIONS = $00000020; // Message memory locations
  139. SIM_CAPSTYPE_ALL = $0000003F; // All of the above
  140. // SMS Storage | SMS storage locations }
  141. SIM_SMSSTORAGE_BROADCAST = $00000001; // Broadcast message storage location
  142. SIM_SMSSTORAGE_SIM = $00000002; // SIM storage location
  143. SIM_NUMSMSSTORAGES = 2; // Number of message storage locations
  144. // Address Type | Defines different address types }
  145. SIM_ADDRTYPE_UNKNOWN = $00000000; // Unknown
  146. SIM_ADDRTYPE_INTERNATIONAL = $00000001; // International number
  147. SIM_ADDRTYPE_NATIONAL = $00000002; // National number
  148. SIM_ADDRTYPE_NETWKSPECIFIC = $00000003; // Network specific number
  149. SIM_ADDRTYPE_SUBSCRIBER = $00000004; // Subscriber number (protocol-specific)
  150. SIM_ADDRTYPE_ALPHANUM = $00000005; // Alphanumeric address
  151. SIM_ADDRTYPE_ABBREV = $00000006; // Abbreviated number
  152. // Numbering Plan | Defines different numbering plans for SIM_ADDRTYPE_UNKNOWN,
  153. // SIM_ADDRTYPE_INTERNATIONAL, and SIM_ADDRTYPE_NATIONAL
  154. SIM_NUMPLAN_UNKNOWN = $00000000; // Unknown
  155. SIM_NUMPLAN_TELEPHONE = $00000001; // ISDN/telephone numbering plan (E.164/E.163)
  156. SIM_NUMPLAN_DATA = $00000002; // Data numbering plan (X.121)
  157. SIM_NUMPLAN_TELEX = $00000003; // Telex numbering plan
  158. SIM_NUMPLAN_NATIONAL = $00000004; // National numbering plan
  159. SIM_NUMPLAN_PRIVATE = $00000005; // Private numbering plan
  160. SIM_NUMPLAN_ERMES = $00000006; // ERMES numbering plan (ETSI DE/PS 3 01-3)
  161. // Phone Locked | Indicates if the phone is currently locked (i.e.
  162. // awaiting password) and what password to enter
  163. SIM_LOCKEDSTATE_UNKNOWN = $00000000; // Locking state is unknown
  164. SIM_LOCKEDSTATE_READY = $00000001; // Not awaiting a password (unlocked)
  165. SIM_LOCKEDSTATE_SIM_PIN = $00000002; // Awaiting the SIM PIN
  166. SIM_LOCKEDSTATE_SIM_PUK = $00000003; // Awaiting the SIM PUK
  167. SIM_LOCKEDSTATE_PH_SIM_PIN = $00000004; // Awaiting the Phone to SIM Personalization PIN
  168. SIM_LOCKEDSTATE_PH_FSIM_PIN = $00000005; // Awaiting the Phone to first SIM Personalization PIN
  169. SIM_LOCKEDSTATE_PH_FSIM_PUK = $00000006; // Awaiting the Phone to first SIM Personalization PUK
  170. SIM_LOCKEDSTATE_SIM_PIN2 = $00000007; // Awaiting the SIM PIN2
  171. SIM_LOCKEDSTATE_SIM_PUK2 = $00000008; // Awaiting the SIM PUK2
  172. SIM_LOCKEDSTATE_PH_NET_PIN = $00000009; // Awaiting the Network Personalization PIN
  173. SIM_LOCKEDSTATE_PH_NET_PUK = $0000000a; // Awaiting the Network Personalization PUK
  174. SIM_LOCKEDSTATE_PH_NETSUB_PIN = $0000000b; // Awaiting the Network Subset Personalization PIN
  175. SIM_LOCKEDSTATE_PH_NETSUB_PUK = $0000000c; // Awaiting the Network Subset Personalization PUK
  176. SIM_LOCKEDSTATE_PH_SP_PIN = $0000000d; // Awaiting the Service Provider Personalization PIN
  177. SIM_LOCKEDSTATE_PH_SP_PUK = $0000000e; // Awaiting the Service Provider Personalization PUK
  178. SIM_LOCKEDSTATE_PH_CORP_PIN = $0000000f; // Awaiting the Corporate Personalization PIN
  179. SIM_LOCKEDSTATE_PH_CORP_PUK = $00000010; // Awaiting the Corporate Personalization PUK
  180. // Phonebook Misc | Special phonebook constants }
  181. SIM_PBINDEX_FIRSTAVAILABLE = $ffffffff; // Use first phonebook storage entry available
  182. // Phone Locking | Indicates the phone's locking behavior }
  183. SIM_LOCKFACILITY_CNTRL = $00000001; // Lock control curface
  184. SIM_LOCKFACILITY_PH_SIM = $00000002; // Lock phone to SIM card
  185. SIM_LOCKFACILITY_PH_FSIM = $00000004; // Lock phone to first SIM card
  186. SIM_LOCKFACILITY_SIM = $00000008; // Lock SIM card
  187. SIM_LOCKFACILITY_SIM_PIN2 = $00000010; // Lock SIM card
  188. SIM_LOCKFACILITY_SIM_FIXEDIALING = $00000020; // SIM fixed dialing memory
  189. SIM_LOCKFACILITY_NETWORKPERS = $00000040; // Network personalization
  190. SIM_LOCKFACILITY_NETWORKSUBPERS = $00000080; // Network subset personalization
  191. SIM_LOCKFACILITY_SERVICEPROVPERS = $00000100; // Service provider personalization
  192. SIM_LOCKFACILITY_CORPPERS = $00000200; // Corporate personalization
  193. SIM_NUMLOCKFACILITIES = 10; // Number of locking facilities
  194. // SIM Record | Different SIM file types
  195. SIM_RECORDTYPE_UNKNOWN = $00000000; // An unknown file type
  196. SIM_RECORDTYPE_TRANSPARENT = $00000001; // A single veriable lengthed record
  197. SIM_RECORDTYPE_CYCLIC = $00000002; // A cyclic set of records, each of the same length
  198. SIM_RECORDTYPE_LINEAR = $00000003; // A linear set of records, each of the same length
  199. SIM_RECORDTYPE_MASTER = $00000004; // Every SIM has a single master record, effectively the head node
  200. SIM_RECORDTYPE_DEDICATED = $00000005; // Effectively a "directory" file which is a parent of other records
  201. // SIM Record Refresh | Different ways of being notified that SIM
  202. // have been updated
  203. SIMFILE_FULLFILECHANGE = $00000001; // All files have been changed
  204. SIMFILE_FILECHANGE = $00000002; // Only a few files have been changed
  205. SIMFILE_SIMINIT = $00000004; // SIM Initiailization
  206. SIMFILE_SIMRESET = $00000008; // Reset the SIM
  207. // Max_Length | Maximum length constants }
  208. MAX_LENGTH_ADDRESS = 256; // Maximum length of an address
  209. MAX_LENGTH_PHONEBOOKENTRYTEXT = 256; // Maximum length of text in a phonebook entry
  210. MAX_LENGTH_HEADER = 256; // Maximum length of a SMS header
  211. MAX_LENGTH_MESSAGE = 256; // Maximum length of a SMS message
  212. MAX_FILES = 32; // Maximum number of files in a file change list
  213. //*****************************************************************************
  214. // types
  215. //*****************************************************************************
  216. type
  217. // HSIM | Handle to a SIM }
  218. HSIM = HANDLE;
  219. LPHSIM = ^HSIM;
  220. // SIMPHONEBOOKENTRY | A SIM phonebook entry
  221. simphonebookentry_tag = record
  222. cbSize : DWORD; // Size of the structure in bytes
  223. dwParams : DWORD; // Indicates valid parameter values
  224. lpszAddress : array[0..(MAX_LENGTH_ADDRESS)-1] of TCHAR; // The actual phone number
  225. dwAddressType : DWORD; // A SIM_ADDRTYPE_* constant
  226. dwNumPlan : DWORD; // A SIM_NUMPLAN_* constant
  227. lpszText : array[0..(MAX_LENGTH_PHONEBOOKENTRYTEXT)-1] of TCHAR; // Text assocaited with the entry
  228. end;
  229. TSIMPHONEBOOKENTRY = simphonebookentry_tag;
  230. LPSIMPHONEBOOKENTRY = ^simphonebookentry_tag;
  231. // SIMMESSAGE | A SIM message entry
  232. simmessage_tag = record
  233. cbSize : DWORD; // Size of the structure in bytes
  234. dwParams : DWORD; // Indicates valid parameter values
  235. lpszAddress : array[0..(MAX_LENGTH_ADDRESS)-1] of TCHAR; // The actual phone number
  236. dwAddressType : DWORD; // A SIM_ADDRTYPE_* constant
  237. dwNumPlan : DWORD; // A SIM_NUMPLAN_* constant
  238. stReceiveTime : SYSTEMTIME; // Timestamp for the incoming message
  239. cbHdrLength : DWORD; // Header length in bytes
  240. rgbHeader : array[0..(MAX_LENGTH_HEADER)-1] of BYTE; // The actual header data
  241. lpszMessage : array[0..(MAX_LENGTH_MESSAGE)-1] of TCHAR; // The actual message data
  242. end;
  243. TSIMMESSAGE = simmessage_tag;
  244. LPSIMMESSAGE = ^simmessage_tag;
  245. // SIMLOCKINGPWDLENGTH | Minimum password length }
  246. simlockingpwdlength = record
  247. dwFacility : DWORD; // The locking facility
  248. dwPasswordLength : DWORD; // The minimum password length
  249. end;
  250. LPSIMLOCKINGPWDLENGTH = ^simlockingpwdlength;
  251. // SIMCAPS | Capabilities of the SIM
  252. simcaps_tag = record
  253. cbSize : DWORD; // Size of the structure in bytes
  254. dwParams : DWORD; // Indicates valid parameter values
  255. dwPBStorages : DWORD; // Supported phonebook storages
  256. dwMinPBIndex : DWORD; // Minimum phonebook storages
  257. dwMaxPBIndex : DWORD; // Maximum phonebook storages
  258. dwMaxPBEAddressLength : DWORD; // Maximum address length of phonebook entries
  259. dwMaxPBETextLength : DWORD; // Maximum text length of phonebook entries
  260. dwLockFacilities : DWORD; // Supported locking facilities
  261. dwReadMsgStorages : DWORD; // Supported read message stores
  262. dwWriteMsgStorages : DWORD; // Supported write message stores
  263. dwNumLockingPwdLengths : DWORD; // Number of entries in rgLockingPwdLengths
  264. rgLockingPwdLengths : array[0..(SIM_NUMLOCKFACILITIES)-1] of SIMLOCKINGPWDLENGTH; // Password lengths for each facility
  265. end;
  266. TSIMCAPS = simcaps_tag;
  267. LPSIMCAPS = ^simcaps_tag;
  268. // SIMRECORDINFO | Information about a particular SIM file
  269. simrecordinfo_tag = record
  270. cbSize : DWORD; // Size of the structure in bytes
  271. dwParams : DWORD; // Indicates valid parameter values
  272. dwRecordType : DWORD; // SIM_RECORDTYPE_* Constant
  273. dwItemCount : DWORD; // Number of items in the record
  274. dwSize : DWORD; // Size in bytes of each item
  275. end;
  276. TSIMRECORDINFO = simrecordinfo_tag;
  277. LPSIMRECORDINFO = ^simrecordinfo_tag;
  278. // SIMFILEREFRESH | Information about which file(s) have been updated
  279. simfilerefresh_tag = record
  280. cbSize : DWORD; // Size of the structure in bytes
  281. dwParams : DWORD; // Indicates valid parameter values
  282. dwFlags : DWORD; // Combination of SIMFILE_* constants
  283. dwFileCount : DWORD; // Number of files in the update list
  284. rgdwAddress : array[0..(MAX_FILES)-1] of DWORD; // Array of files
  285. end;
  286. TSIMFILEREFRESH = simfilerefresh_tag;
  287. LPSIMFILEREFRESH = ^simfilerefresh_tag;
  288. // SIMPBECHANGE | Information about which SIM Phonebook entries have changed
  289. simpbechange_tag = record
  290. dwEntry : DWORD; // The index of the entry that has changed
  291. dwStorage : DWORD; // SIM_PBSTORAGE_* constant detailing which phonebook this entry is in
  292. end;
  293. TSIMPBECHANGE = simpbechange_tag;
  294. LPSIMPBECHANGE = ^simpbechange_tag;
  295. // SIMMESSAGECHANGE | Information about which SMS messages on the SIM have changed }
  296. simmessagechange_tag = record
  297. dwEntry : DWORD; // The index of the entry that has changed
  298. dwStorage : DWORD; // SIM_SMSSTORAGE_* constant details which storage location this entry is in
  299. end;
  300. TSIMMESSAGECHANGE = simmessagechange_tag;
  301. LPSIMMESSAGECHANGE = ^simmessagechange_tag;
  302. // This is the callback function prototype used by SIM Manager when
  303. // sending notifications.
  304. // -
  305. // Indicates type of notification received
  306. // Points to data structure specific to the notification
  307. // Size of data structure in bytes
  308. // Parameter passed to simInititialize
  309. TSIMCALLBACK = procedure (dwNotifyCode:DWORD; const pData:pointer; dwDataSize:DWORD; dwParam:DWORD);
  310. //*****************************************************************************
  311. // functions
  312. //*****************************************************************************
  313. // This function must be called by applications in order to use any of the
  314. // functions in this API.
  315. // Passing in a function callback is required only for applications that
  316. // wish to obtain notifications.
  317. // -
  318. // Indicates which notifications to receive
  319. // Function callback for notifications, may be NULL if notifications are not desired
  320. // Parameter to pass on each notification function call, may be NULL
  321. // Points to a HSIM handle to use on subsequent function calls
  322. function SimInitialize(dwFlags:DWORD; lpfnCallBack:TSIMCALLBACK; dwParam:DWORD; lphSim:LPHSIM):HRESULT;external KernelDLL name 'SimInitialize';
  323. // This function deinitializes an HSIM handle.
  324. // -
  325. // A valid HSIM handle to deinitialize
  326. function SimDeinitialize(hSim:HSIM):HRESULT;external KernelDLL name 'SimDeinitialize';
  327. // Gets the device capabilities of the SIM.
  328. // -
  329. // Points to a valid HSIM handle
  330. // Which device capabilities are we interested in?
  331. // Capabilities structure
  332. function SimGetDevCaps(hSim:HSIM; dwCapsType:DWORD; lpSimCaps:LPSIMCAPS):HRESULT;external KernelDLL name 'SimGetDevCaps';
  333. // Reads a phonebook entry off the SIM card.
  334. // -
  335. // Points to a valid HSIM handle
  336. // A SIMPBSTORAGE_* Constant
  337. // Index of the entry to retrieve
  338. // Points to a phonebook entry structure
  339. function SimReadPhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD; lpPhonebookEntry:LPSIMPHONEBOOKENTRY):HRESULT;external KernelDLL name 'SimReadPhonebookEntry';
  340. // Gets the status of a phonebook location.
  341. // -
  342. // Points to a valid HSIM handle
  343. // A SIMPBSTORAGE_* Constant
  344. // Nubmer of used locations
  345. // Total number of locations
  346. function SimGetPhonebookStatus(hSim:HSIM; dwLocation:DWORD; lpdwUsed:LPDWORD; lpdwTotal:LPDWORD):HRESULT;external KernelDLL name 'SimGetPhonebookStatus';
  347. // Writes a phonebook entry to the SIM card.
  348. // -
  349. // Points to a valid HSIM handle
  350. // A SIMPBSTORAGE_* Constant
  351. // Index of the entry to retrieve (may be SIM_PBINDEX_FIRSTAVAILABLE)
  352. // Points to a phonebook entry structure
  353. function SimWritePhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD; lpPhonebookEntry:LPSIMPHONEBOOKENTRY):HRESULT;external KernelDLL name 'SimWritePhonebookEntry';
  354. // Deletes a phonebook entry from the SIM card.
  355. // -
  356. // Points to a valid HSIM handle
  357. // A SIMPBSTORAGE_* Constant
  358. // Index of the entry to retrieve
  359. function SimDeletePhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD):HRESULT;external KernelDLL name 'SimDeletePhonebookEntry';
  360. // Checks if the SIM is currently awaiting a password.
  361. // This is called when powering on the phone.
  362. // -
  363. // Points to a valid HSIM handle
  364. // Points to a SIM_LOCKEDSTATE_* constant
  365. function SimGetPhoneLockedState(hSim:HSIM; lpdwLockedState:LPDWORD):HRESULT;external KernelDLL name 'SimGetPhoneLockedState';
  366. // Sends a password to unlock the phone.
  367. // -
  368. // Points to a valid HSIM handle
  369. // Points to password string
  370. // Some locked states require a second password (e.g. PUK requires a new PIN to replace the old, presumably forgotten PIN)
  371. function SimUnlockPhone(hSim:HSIM; lpszPassword:LPTSTR; lpszNewPin:LPTSTR):HRESULT;external KernelDLL name 'SimUnlockPhone';
  372. // Gets the locking status of the phone.
  373. // -
  374. // Points to a valid HSIM handle
  375. // A SIMLOCKFACILITY_* constant
  376. // Some facilities require a password
  377. // Enabled or diabled
  378. function SimGetLockingStatus(hSim:HSIM; dwLockingFacility:DWORD; lpszPassword:LPTSTR; var pfEnabled:BOOL):HRESULT;external KernelDLL name 'SimGetLockingStatus';
  379. // Sets the locking status of the phone.
  380. // -
  381. // Points to a valid HSIM handle
  382. // A SIMLOCKFACILITY_* constant
  383. // Some facilities require a password
  384. // Enable or diable
  385. function SimSetLockingStatus(hSim:HSIM; dwLockingFacility:DWORD; lpszPassword:LPTSTR; fEnabled:BOOL):HRESULT;external KernelDLL name 'SimSetLockingStatus';
  386. // Changes a locking password.
  387. // -
  388. // Points to a valid HSIM handle
  389. // A SIMLOCKFACILITY_* constant
  390. // The old password
  391. // The new password
  392. function SimChangeLockingPassword(hSim:HSIM; dwLockingFacility:DWORD; lpszOldPassword:LPTSTR; lpszNewPassword:LPTSTR):HRESULT;external KernelDLL name 'SimChangeLockingPassword';
  393. // Gets the status of a SMS storage location.
  394. // -
  395. // Points to a valid HSIM handle
  396. // A SIM_SMSSTORAGE_* constant
  397. // Nubmer of used locations
  398. // Total number of locations
  399. function SimGetSmsStorageStatus(hSim:HSIM; dwStorage:DWORD; lpdwUsed:LPDWORD; lpdwTotal:LPDWORD):HRESULT;external KernelDLL name 'SimGetSmsStorageStatus';
  400. // Reads an SMS from a particular storage location.
  401. // -
  402. // Points to a valid HSIM handle
  403. // A SIM_SMSSTORAGE_* constant
  404. // Index of the entry to retrieve
  405. // Points to an SMS message structure
  406. function SimReadMessage(hSim:HSIM; dwStorage:DWORD; dwIndex:DWORD; lpSimMessage:LPSIMMESSAGE):HRESULT;external KernelDLL name 'SimReadMessage';
  407. // Writes an SMS to a particular storage location.
  408. // Note that SMS messages are always written to the first available storage location
  409. // -
  410. // lpdwIndex will be set to the index to which the message was written
  411. // Points to a valid HSIM handle
  412. // A SIM_SMSSTORAGE_* constant
  413. // Set to the index where the message was written
  414. // Points to an SMS message structure
  415. function SimWriteMessage(hSim:HSIM; dwStorage:DWORD; lpdwIndex:LPDWORD; lpSimMessage:LPSIMMESSAGE):HRESULT;external KernelDLL name 'SimWriteMessage';
  416. // Deletes an SMS from a particular storage location.
  417. // -
  418. // Points to a valid HSIM handle
  419. // A SIM_SMSSTORAGE_* constant
  420. // Index of the entry to retrieve
  421. function SimDeleteMessage(hSim:HSIM; dwStorage:DWORD; dwIndex:DWORD):HRESULT;external KernelDLL name 'SimDeleteMessage';
  422. // Reads a file form the SIM.
  423. // -
  424. // Points to a valid HSIM handle
  425. // SIM address
  426. // A SIM_RECORDTYPE_* constant
  427. // Applies only to SIM_RECORDTYPE_CYCLIC and SIM_RECORDTYPE_LINEAR, otherwise ignored
  428. // Data buffer
  429. // Size of data buffer
  430. // Number of bytes read
  431. function SimReadRecord(hSim:HSIM; dwAddress:DWORD; dwRecordType:DWORD; dwIndex:DWORD;
  432. lpData: LPBYTE; dwBufferSize: DWORD; lpdwBytesRead: LPDWORD):HRESULT;external KernelDLL name 'SimReadRecord';
  433. // Writes a file to the SIM.
  434. // -
  435. // Points to a valid HSIM handle
  436. // SIM address
  437. // A SIM_RECORDTYPE_* constant
  438. // Applies only to SIM_RECORDTYPE_CYCLIC and SIM_RECORDTYPE_LINEAR, otherwise ignored
  439. function SimWriteRecord(hSim:HSIM; dwAddress:DWORD; dwRecordType:DWORD; dwIndex:DWORD;
  440. lpData: LPBYTE; dwByteCount: DWORD):HRESULT;external KernelDLL name 'SimWriteRecord';
  441. // Gets information about a particular record.
  442. // -
  443. // Points to a valid HSIM handle
  444. // SIM address
  445. // Points to a SIM record information structure
  446. function SimGetRecordInfo(hSim:HSIM; dwAddress:DWORD; lpSimRecordInfo:LPSIMRECORDINFO):HRESULT;external KernelDLL name 'SimGetRecordInfo';
  447. {$endif read_interface}
  448. {$ifdef read_implementation}
  449. {$endif read_implementation}