projects.pp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2008 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. //
  11. // File: project.h
  12. //
  13. // Abstract:
  14. //
  15. // Contents:
  16. // Project APIs defines
  17. //
  18. //
  19. // Microsoft Windows Mobile 6.0 for PocketPC SDK.
  20. //
  21. unit projects;
  22. {$CALLING cdecl}
  23. interface
  24. uses Windows;
  25. const
  26. Note_prjDLL = 'note_prj.dll';
  27. type
  28. tagENUM = (PRJ_ENUM_MEMORY := $01, // enumerate main memory projects only
  29. PRJ_ENUM_FLASH := $02, // enumerate flash card projects only
  30. PRJ_ENUM_ALL_DEVICES := $04, // enumerate main memory projects & Flash card,
  31. PRJ_ENUM_ALL_PROJ := $10, // enumerate in all projects
  32. PRJ_ENUM_HOME_PROJ := $0100 // add 'My Documents' home folder
  33. );
  34. PRJ_ENUM = tagENUM;
  35. //////////////////////////////////////////////////////////////////////////////
  36. // THE "OID" PROBLEM
  37. //
  38. // The OS changed from returning faked OIDs for
  39. // storage cards and other FAT file systems to returning invalid / -1. This
  40. // seriously messes up anything that wants to uses OIDs to identify objects
  41. // on a storage card.
  42. //
  43. type
  44. PFNCOLCUSTOK = function(iParam1:HWND; iParam2:LPVOID):BOOL; cdecl;
  45. PROJECTS_ENUMPROC = function(iParam1:DWORD; iParam2:LPARAM):BOOL; cdecl;
  46. PROJECTSFILES_ENUMPROC = function(idwOID:DWORD; ilParam:LPARAM):BOOL; cdecl;
  47. {*****************************************************************************
  48. EnumProjects Exported API: Enumerates all projects on the specified file
  49. system.
  50. PARAMETERS:
  51. pfnEnumProc pointer to callback function. If NULL, this function simply
  52. returns the number of projects, without enumerating through them.
  53. If the callback function ever returns FALSE, the enumeration will
  54. halt. The callback has the following prototype:
  55. BOOL CALLBACK EnumProjectsCallback(DWORD dwOid, LPARAM lParam);
  56. dwOidFlash Only used for (dwFlags == PRJ_ENUM_FLASH). This is the OID of
  57. the flash card to look at; the value returned by
  58. FindFirstFlashCard or FindNextFlashCard.
  59. dwFlags
  60. Any combo of the following (specifying the LOCATION to check):
  61. PRJ_ENUM_MEMORY - check all main memory projects/folders,
  62. dwOidFlash is not used
  63. PRJ_ENUM_FLASH - check all projects on the specified flash card,
  64. where dwOidFlash specifies the flash card to
  65. examine.
  66. PRJ_ENUM_ALL_DEVICES - check all projects/folders from main memory,
  67. and from *every* flash card. (dwOid is not used)
  68. lParam user defined parameter passed to pfnEnumProc
  69. RETURN:
  70. The total number of projects. NOTE: this is actually the total number of
  71. projects in MAIN MEMORY ONLY (see below).
  72. THIS IS PROVIDED FOR BACKWARD COMPATIBILITY. It will silently skip over any
  73. project that isn't on an OID-based filesystem (it enumerates everything in
  74. main memory, but will silently skip everything on storage cards). The modern
  75. function is EnumProjectsEx.
  76. ******************************************************************************}
  77. function EnumProjects(lpEnumProc:PROJECTS_ENUMPROC; dwOid:DWORD; dwFlags:DWORD; lParam:LPARAM):longint; external Note_prjDLL name 'EnumProjects';
  78. {*****************************************************************************
  79. EnumProjectsFiles Exported API: Enumaretes all files in a project on the
  80. specified file system.
  81. PARAMETERS:
  82. pfnEnumProc pointer to callback function. If NULL, this function simply
  83. returns the number of files without enumerating through them.
  84. If the callback function ever returns FALSE, the enumeration will
  85. halt. The callback has the following prototype:
  86. (normal) BOOL CALLBACK EnumProjectFilesCallback(DWORD dwOID, LPARAM lParam);
  87. (ex ver) BOOL CALLBACK EnumProjectFilesExCallback(PAstruct* pPA, LPARAM lParam);
  88. dwOidFlash Only used for (dwFlags & PRJ_ENUM_FLASH). This is the OID of
  89. the flash card to look at; the value returned by
  90. FindFirstFlashCard or FindNextFlashCard.
  91. dwFlags
  92. Any combo of the following (specifying the LOCATION to check):
  93. PRJ_ENUM_MEMORY - check all main memory projects/folders,
  94. dwOidFlash is not used
  95. PRJ_ENUM_FLASH - check all projects on the specified flash card,
  96. where dwOidFlash specifies the flash card to
  97. examine.
  98. PRJ_ENUM_ALL_DEVICES - check all projects/folders from main memory,
  99. and from *every* flash card. (dwOid is not used)
  100. Plus any of the following (specifying which PROJECTS to check):
  101. PRJ_ENUM_ALL_PROJ- enumerate in all project (szProj is not used)
  102. szProj Only used for when (dwFlags & PRJ_ENUM_ALL_PROJ) is NOT set. This
  103. specifies which project to search; NULL specifies to look for files
  104. that aren't in a project/folder (i.e., they're at the top level,
  105. under "\My Documents").
  106. szFileName pointer to name of file to search for. (i.e. '*.wav' or '*.*')
  107. lParam user defined parameter passed to pfnEnumProc
  108. RETURN:
  109. The total number of matching files found. NOTE: in the regular version,
  110. this is actually the total number of files in MAIN MEMORY ONLY (see below).
  111. The regular version is provided for backward compatibility. It will silently
  112. skip over any file that isn't on an OID-based filesystem (it enumerates
  113. everything in main memory, but will silently skip everything on storage cards).
  114. The modern version, EnumProjectsFilesEx, requires the extended callback
  115. function, too.
  116. ******************************************************************************}
  117. function EnumProjectsFiles(lpEnumProc:PROJECTSFILES_ENUMPROC;
  118. dwOidFlash:DWORD;
  119. dwFlags:DWORD;
  120. lpszProj:LPTSTR;
  121. lpszFileName:LPTSTR;
  122. lParam:LPARAM):longint; external Note_prjDLL name 'EnumProjectsFiles';
  123. {**************************************************************************************************
  124. FindFirstFlashCard
  125. Find the first mountable file system
  126. lpFindProjData - pointer to returned information
  127. **************************************************************************************************}
  128. function FindFirstFlashCard(lpFindFlashData:LPWIN32_FIND_DATA):HANDLE; external Note_prjDLL name 'FindFirstFlashCard';
  129. {**************************************************************************************************
  130. FindNextFlashCard
  131. Find the next mountable file system
  132. lpFindProjData - pointer to returned information
  133. hFindFlash - Identifies a search handle returned by a previous call to the FindFirstFlashCard function.
  134. **************************************************************************************************}
  135. function FindNextFlashCard(hFindFlash:HANDLE; lpFindFlashData:LPWIN32_FIND_DATA):BOOL; external Note_prjDLL name 'FindNextFlashCard';
  136. {**************************************************************************************************
  137. FindFirstProjectFile
  138. Find the first file in a project, on the desired mountable file system
  139. lpFileName - pointer to name of file to search for (i.e: '*.wav')
  140. lpFindFileData - pointer to returned information
  141. dwOidFlash - Oid to the desired mountable file system (FindFirstFlashCard or FindNextFlashCard)
  142. or 0 if main memory
  143. lpszProj - desired project, or NULL (or 'All') to search for files that do not
  144. have a project (under '\My Documents')
  145. **************************************************************************************************}
  146. function FindFirstProjectFile(lpFileName:LPCTSTR;
  147. lpFindFileData:LPWIN32_FIND_DATA;
  148. dwOidFlash:DWORD;
  149. szProject:LPTSTR):HANDLE; external Note_prjDLL name 'FindFirstProjectFile';
  150. {**************************************************************************************************
  151. FindNextProjectFile
  152. Find the next file in a project
  153. lpFindProjData - pointer to returned information
  154. hFind - Identifies a search handle returned by a previous call to the FindFirstProjectFile function.
  155. **************************************************************************************************}
  156. function FindNextProjectFile(hFindFlash:HANDLE; lpFindFlashData:LPWIN32_FIND_DATA):BOOL; external Note_prjDLL name 'FindNextProjectFile';
  157. // new code, it solves the "OID Problem"
  158. //////////////////////////////////////////////////////////////////////////////
  159. // PAstruct:
  160. // This is pretty much a drop-in replacement for the spot where OIDs are
  161. // currently used. Instead of passing around a DWORD, we now pass a pointer
  162. // to this struct. IMPORTANT: callers are responsible for allocating and
  163. // freeing the string memory for file paths.
  164. type
  165. _EFileIDType = (FILE_ID_TYPE_OID := 0, // This file is specified through an OID
  166. FILE_ID_TYPE_PATH := 1, // This file is specified through its pathname
  167. FILE_ID_LAST := 2 // last value in the list (invalid)
  168. );
  169. EFileIDType = _EFileIDType;
  170. const
  171. PA_MAX_PATHNAME = 96; // including null terminator, practically speaking,
  172. // might be " \storage card 3\My Documents\document
  173. // folder 7\very long filename.wav" or 69 char's max
  174. // Pure-NT machines don't necessarily define CEOID. In the future, we'll want
  175. // to replace this define with the actual typedef (JParks).
  176. {$IFNDEF CEOID} // #ifndef CEOID
  177. type
  178. CEOID = DWORD;
  179. {$ENDIF CEOID} // #endif
  180. type
  181. _PAstruct = record // "PA" (Pathname Array) OID-NUMBER REPLACEMENT STRUCTURE
  182. m_IDtype:EFileIDType; // is this an OID or a pathname?
  183. case longint of
  184. 0: (m_fileOID:CEOID); // we're storing the OID
  185. 1: (m_szPathname:array[0..PA_MAX_PATHNAME-1] of TCHAR); // we're storing the full pathname\filename
  186. end;
  187. PAstruct = _PAstruct;
  188. PPAstruct = ^_PAstruct;
  189. type
  190. PROJECTS_ENUMPROC_EX =function(pPA:PPAstruct; lParam:LPARAM):BOOL; cdecl;
  191. PROJECTSFILES_ENUMPROC_EX = function(pPA:PPAstruct; lParam:LPARAM):BOOL; cdecl;
  192. {*****************************************************************************
  193. EnumProjectsEx Exported API: Enumerates all projects on the specified file
  194. system.
  195. PARAMETERS:
  196. pfnEnumProc pointer to callback function. If NULL, this function simply
  197. returns the number of projects, without enumerating through them.
  198. If the callback function ever returns FALSE, the enumeration will
  199. halt. The callback has the following prototype:
  200. BOOL CALLBACK EnumProjectsExCallback(PAstruct* pPA, LPARAM lParam);
  201. dwOidFlash Only used for (dwFlags == PRJ_ENUM_FLASH). This is the OID of
  202. the flash card to look at; the value returned by
  203. FindFirstFlashCard or FindNextFlashCard.
  204. dwFlags
  205. Any combo of the following (specifying the LOCATION to check):
  206. PRJ_ENUM_MEMORY - check all main memory projects/folders,
  207. dwOidFlash is not used
  208. PRJ_ENUM_FLASH - check all projects on the specified flash card,
  209. where dwOidFlash specifies the flash card to
  210. examine.
  211. PRJ_ENUM_ALL_DEVICES - check all projects/folders from main memory,
  212. and from *every* flash card. (dwOid is not used)
  213. lParam user defined parameter passed to pfnEnumProc
  214. RETURN:
  215. The total number of projects *including* storage cards.
  216. This enhanced version can enumerate through both new (OID-based) file systems
  217. and older (DOS-style) filesystems -- including storage cards.
  218. ******************************************************************************}
  219. function EnumProjectsEx(pfnEnumProc:PROJECTS_ENUMPROC_EX;
  220. dwOidFlash:DWORD;
  221. dwFlags:DWORD;
  222. lParam:LPARAM):longint; external Note_prjDLL name 'EnumProjectsEx';
  223. {*****************************************************************************
  224. EnumProjectsFiles Exported API: Enumaretes all files in a project on the
  225. specified file system.
  226. PARAMETERS:
  227. pfnEnumProc pointer to callback function. If NULL, this function simply
  228. returns the number of files without enumerating through them.
  229. If the callback function ever returns FALSE, the enumeration will
  230. halt. The callback has the following prototype:
  231. (normal) BOOL CALLBACK EnumProjectFilesCallback(DWORD dwOID, LPARAM lParam);
  232. (ex ver) BOOL CALLBACK EnumProjectFilesExCallback(PAstruct* pPA, LPARAM lParam);
  233. dwOidFlash Only used for (dwFlags & PRJ_ENUM_FLASH). This is the OID of
  234. the flash card to look at; the value returned by
  235. FindFirstFlashCard or FindNextFlashCard.
  236. dwFlags
  237. Any combo of the following (specifying the LOCATION to check):
  238. PRJ_ENUM_MEMORY - check all main memory projects/folders,
  239. dwOidFlash is not used
  240. PRJ_ENUM_FLASH - check all projects on the specified flash card,
  241. where dwOidFlash specifies the flash card to
  242. examine.
  243. PRJ_ENUM_ALL_DEVICES - check all projects/folders from main memory,
  244. and from *every* flash card. (dwOid is not used)
  245. Plus any of the following (specifying which PROJECTS to check):
  246. PRJ_ENUM_ALL_PROJ- enumerate in all project (szProj is not used)
  247. szProj Only used for when (dwFlags & PRJ_ENUM_ALL_PROJ) is NOT set. This
  248. specifies which project to search; NULL specifies to look for files
  249. that aren't in a project/folder (i.e., they're at the top level,
  250. under "\My Documents").
  251. szFileName pointer to name of file to search for. (i.e. '*.wav' or '*.*')
  252. lParam user defined parameter passed to pfnEnumProc
  253. RETURN:
  254. The total number of matching files found. NOTE: in the regular version,
  255. this is actually the total number of files in MAIN MEMORY ONLY (see below).
  256. The regular version is provided for backward compatibility. It will silently
  257. skip over any file that isn't on an OID-based filesystem (it enumerates
  258. everything in main memory, but will silently skip everything on storage cards).
  259. The modern version, EnumProjectsFilesEx, requires the extended callback
  260. function, too.
  261. ******************************************************************************}
  262. function EnumProjectsFilesEx(pfnEnumProc:PROJECTSFILES_ENUMPROC_EX;
  263. dwOidFlash:DWORD;
  264. dwFlags:DWORD;
  265. szProj:LPTSTR;
  266. szFileName:LPTSTR;
  267. lParam:LPARAM):longint; external Note_prjDLL name 'EnumProjectsFilesEx';
  268. implementation
  269. end.