Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

404 lines
14 KiB

  1. /************************************************************************
  2. * Copyright (c) Wonderware Software Development Corp. 1991-1993. *
  3. * All Rights Reserved. *
  4. * Copyright (c) Microsoft Inc. 1995-1999 *
  5. * All Rights Reserved. *
  6. ************************************************************************/
  7. #ifndef _INC_NDDEAPI
  8. #define _INC_NDDEAPI
  9. #if _MSC_VER > 1000
  10. #pragma once
  11. #endif
  12. #include <pshpack1.h> /* Assume byte packing throughout */
  13. #ifdef __cplusplus
  14. extern "C" { /* Assume C declarations for C++ */
  15. #endif /* __cplusplus */
  16. #ifndef CNLEN /* If not included with netapi header */
  17. #define CNLEN 15 /* Computer name length */
  18. #define UNCLEN (CNLEN+2) /* UNC computer name length */
  19. #endif /* CNLEN */
  20. // the choice of this char affects legal share,topic, etc. names
  21. #define SEP_CHAR ','
  22. #define BAR_CHAR "|"
  23. #define SEP_WCHAR L','
  24. #define BAR_WCHAR L"|"
  25. /* API error codes */
  26. #define NDDE_NO_ERROR 0
  27. #define NDDE_ACCESS_DENIED 1
  28. #define NDDE_BUF_TOO_SMALL 2
  29. #define NDDE_ERROR_MORE_DATA 3
  30. #define NDDE_INVALID_SERVER 4
  31. #define NDDE_INVALID_SHARE 5
  32. #define NDDE_INVALID_PARAMETER 6
  33. #define NDDE_INVALID_LEVEL 7
  34. #define NDDE_INVALID_PASSWORD 8
  35. #define NDDE_INVALID_ITEMNAME 9
  36. #define NDDE_INVALID_TOPIC 10
  37. #define NDDE_INTERNAL_ERROR 11
  38. #define NDDE_OUT_OF_MEMORY 12
  39. #define NDDE_INVALID_APPNAME 13
  40. #define NDDE_NOT_IMPLEMENTED 14
  41. #define NDDE_SHARE_ALREADY_EXIST 15
  42. #define NDDE_SHARE_NOT_EXIST 16
  43. #define NDDE_INVALID_FILENAME 17
  44. #define NDDE_NOT_RUNNING 18
  45. #define NDDE_INVALID_WINDOW 19
  46. #define NDDE_INVALID_SESSION 20
  47. #define NDDE_INVALID_ITEM_LIST 21
  48. #define NDDE_SHARE_DATA_CORRUPTED 22
  49. #define NDDE_REGISTRY_ERROR 23
  50. #define NDDE_CANT_ACCESS_SERVER 24
  51. #define NDDE_INVALID_SPECIAL_COMMAND 25
  52. #define NDDE_INVALID_SECURITY_DESC 26
  53. #define NDDE_TRUST_SHARE_FAIL 27
  54. /* string size constants */
  55. #define MAX_NDDESHARENAME 256
  56. #define MAX_DOMAINNAME 15
  57. #define MAX_USERNAME 15
  58. #define MAX_APPNAME 255
  59. #define MAX_TOPICNAME 255
  60. #define MAX_ITEMNAME 255
  61. /* connectFlags bits for ndde service affix */
  62. #define NDDEF_NOPASSWORDPROMPT 0x0001
  63. #define NDDEF_NOCACHELOOKUP 0x0002
  64. #define NDDEF_STRIP_NDDE 0x0004
  65. /* NDDESHAREINFO - contains information about a NDDE share */
  66. struct NDdeShareInfo_tag {
  67. LONG lRevision;
  68. LPTSTR lpszShareName;
  69. LONG lShareType;
  70. LPTSTR lpszAppTopicList;
  71. LONG fSharedFlag;
  72. LONG fService;
  73. LONG fStartAppFlag;
  74. LONG nCmdShow;
  75. LONG qModifyId[2];
  76. LONG cNumItems;
  77. LPTSTR lpszItemList;
  78. };
  79. typedef struct NDdeShareInfo_tag NDDESHAREINFO;
  80. typedef struct NDdeShareInfo_tag * PNDDESHAREINFO;
  81. /* Share Types */
  82. #define SHARE_TYPE_OLD 0x01 // Excel|sheet1.xls
  83. #define SHARE_TYPE_NEW 0x02 // ExcelWorksheet|sheet1.xls
  84. #define SHARE_TYPE_STATIC 0x04 // ClipSrv|SalesData
  85. /*
  86. Add new share
  87. */
  88. UINT WINAPI
  89. NDdeShareAddA (
  90. LPSTR lpszServer, // server to execute on ( must be NULL )
  91. UINT nLevel, // info level must be 2
  92. PSECURITY_DESCRIPTOR pSD, // initial security descriptor (optional)
  93. LPBYTE lpBuffer, // contains (NDDESHAREINFO) + data
  94. DWORD cBufSize // sizeof supplied buffer
  95. );
  96. UINT WINAPI
  97. NDdeShareAddW (
  98. LPWSTR lpszServer, // server to execute on ( must be NULL )
  99. UINT nLevel, // info level must be 2
  100. PSECURITY_DESCRIPTOR pSD, // initial security descriptor (optional)
  101. LPBYTE lpBuffer, // contains (NDDESHAREINFO) + data
  102. DWORD cBufSize // sizeof supplied buffer
  103. );
  104. /*
  105. Delete a share
  106. */
  107. UINT WINAPI
  108. NDdeShareDelA (
  109. LPSTR lpszServer, // server to execute on ( must be NULL )
  110. LPSTR lpszShareName, // name of share to delete
  111. UINT wReserved // reserved for force level (?) 0 for now
  112. );
  113. UINT WINAPI
  114. NDdeShareDelW (
  115. LPWSTR lpszServer, // server to execute on ( must be NULL )
  116. LPWSTR lpszShareName, // name of share to delete
  117. UINT wReserved // reserved for force level (?) 0 for now
  118. );
  119. /*
  120. Get Share Security Descriptor
  121. */
  122. UINT WINAPI
  123. NDdeGetShareSecurityA(
  124. LPSTR lpszServer, // server to execute on ( must be NULL )
  125. LPSTR lpszShareName, // name of share to delete
  126. SECURITY_INFORMATION si, // requested information
  127. PSECURITY_DESCRIPTOR pSD, // address of security descriptor
  128. DWORD cbSD, // size of buffer for security descriptor
  129. LPDWORD lpcbsdRequired // address of required size of buffer
  130. );
  131. UINT WINAPI
  132. NDdeGetShareSecurityW(
  133. LPWSTR lpszServer, // server to execute on ( must be NULL )
  134. LPWSTR lpszShareName, // name of share to delete
  135. SECURITY_INFORMATION si, // requested information
  136. PSECURITY_DESCRIPTOR pSD, // address of security descriptor
  137. DWORD cbSD, // size of buffer for security descriptor
  138. LPDWORD lpcbsdRequired // address of required size of buffer
  139. );
  140. /*
  141. Set Share Security Descriptor
  142. */
  143. UINT WINAPI
  144. NDdeSetShareSecurityA(
  145. LPSTR lpszServer, // server to execute on ( must be NULL )
  146. LPSTR lpszShareName, // name of share to delete
  147. SECURITY_INFORMATION si, // type of information to set
  148. PSECURITY_DESCRIPTOR pSD // address of security descriptor
  149. );
  150. UINT WINAPI
  151. NDdeSetShareSecurityW(
  152. LPWSTR lpszServer, // server to execute on ( must be NULL )
  153. LPWSTR lpszShareName, // name of share to delete
  154. SECURITY_INFORMATION si, // type of information to set
  155. PSECURITY_DESCRIPTOR pSD // address of security descriptor
  156. );
  157. /*
  158. Enumerate shares
  159. */
  160. UINT WINAPI
  161. NDdeShareEnumA (
  162. LPSTR lpszServer, // server to execute on ( NULL for local )
  163. UINT nLevel, // 0 for null separated 00 terminated list
  164. LPBYTE lpBuffer, // pointer to buffer
  165. DWORD cBufSize, // size of buffer
  166. LPDWORD lpnEntriesRead, // number of names returned
  167. LPDWORD lpcbTotalAvailable // number of bytes available
  168. );
  169. UINT WINAPI
  170. NDdeShareEnumW (
  171. LPWSTR lpszServer, // server to execute on ( NULL for local )
  172. UINT nLevel, // 0 for null separated 00 terminated list
  173. LPBYTE lpBuffer, // pointer to buffer
  174. DWORD cBufSize, // size of buffer
  175. LPDWORD lpnEntriesRead, // number of names returned
  176. LPDWORD lpcbTotalAvailable // number of bytes available
  177. );
  178. /*
  179. Get information on a share
  180. */
  181. UINT WINAPI
  182. NDdeShareGetInfoA (
  183. LPSTR lpszServer, // server to execute on ( must be NULL )
  184. LPSTR lpszShareName, // name of share
  185. UINT nLevel, // info level must be 2
  186. LPBYTE lpBuffer, // gets struct containing (NDDESHAREINFO) + data
  187. DWORD cBufSize, // sizeof buffer
  188. LPDWORD lpnTotalAvailable, // number of bytes available
  189. LPWORD lpnItems // item mask for partial getinfo (must be 0)
  190. );
  191. UINT WINAPI
  192. NDdeShareGetInfoW (
  193. LPWSTR lpszServer, // server to execute on ( must be NULL )
  194. LPWSTR lpszShareName, // name of share
  195. UINT nLevel, // info level must be 2
  196. LPBYTE lpBuffer, // gets struct containing (NDDESHAREINFO) + data
  197. DWORD cBufSize, // sizeof buffer
  198. LPDWORD lpnTotalAvailable, // number of bytes available
  199. LPWORD lpnItems // item mask for partial getinfo (must be 0)
  200. );
  201. /*
  202. Modify DDE share data
  203. */
  204. UINT WINAPI
  205. NDdeShareSetInfoA (
  206. LPSTR lpszServer, // server to execute on ( must be NULL )
  207. LPSTR lpszShareName, // name of share
  208. UINT nLevel, // info level must be 2
  209. LPBYTE lpBuffer, // points to struct with (NDDESHAREINFO) + data
  210. DWORD cBufSize, // sizeof buffer
  211. WORD sParmNum // Parameter index ( must be 0 - entire )
  212. );
  213. UINT WINAPI
  214. NDdeShareSetInfoW (
  215. LPWSTR lpszServer, // server to execute on ( must be NULL )
  216. LPWSTR lpszShareName, // name of share
  217. UINT nLevel, // info level must be 2
  218. LPBYTE lpBuffer, // points to struct with (NDDESHAREINFO) + data
  219. DWORD cBufSize, // sizeof buffer
  220. WORD sParmNum // Parameter index ( must be 0 - entire )
  221. );
  222. /*
  223. Set/Create a trusted share
  224. */
  225. UINT WINAPI
  226. NDdeSetTrustedShareA (
  227. LPSTR lpszServer, // server to execute on ( must be NULL )
  228. LPSTR lpszShareName, // name of share to delete
  229. DWORD dwTrustOptions // trust options to apply
  230. );
  231. UINT WINAPI
  232. NDdeSetTrustedShareW (
  233. LPWSTR lpszServer, // server to execute on ( must be NULL )
  234. LPWSTR lpszShareName, // name of share to delete
  235. DWORD dwTrustOptions // trust options to apply
  236. );
  237. /* Trusted share options */
  238. #define NDDE_TRUST_SHARE_START 0x80000000L // Start App Allowed
  239. #define NDDE_TRUST_SHARE_INIT 0x40000000L // Init Conv Allowed
  240. #define NDDE_TRUST_SHARE_DEL 0x20000000L // Delete Trusted Share (on set)
  241. #define NDDE_TRUST_CMD_SHOW 0x10000000L // Use supplied cmd show
  242. #define NDDE_CMD_SHOW_MASK 0x0000FFFFL // Command Show mask
  243. /*
  244. Get a trusted share options
  245. */
  246. UINT WINAPI
  247. NDdeGetTrustedShareA (
  248. LPSTR lpszServer, // server to execute on ( must be NULL )
  249. LPSTR lpszShareName, // name of share to query
  250. LPDWORD lpdwTrustOptions, // trust options in effect
  251. LPDWORD lpdwShareModId0, // first word of share mod id
  252. LPDWORD lpdwShareModId1 // second word of share mod id
  253. );
  254. UINT WINAPI
  255. NDdeGetTrustedShareW (
  256. LPWSTR lpszServer, // server to execute on ( must be NULL )
  257. LPWSTR lpszShareName, // name of share to query
  258. LPDWORD lpdwTrustOptions, // trust options in effect
  259. LPDWORD lpdwShareModId0, // first word of share mod id
  260. LPDWORD lpdwShareModId1 // second word of share mod id
  261. );
  262. /*
  263. Enumerate trusted shares
  264. */
  265. UINT WINAPI
  266. NDdeTrustedShareEnumA (
  267. LPSTR lpszServer, // server to execute on ( NULL for local )
  268. UINT nLevel, // 0 for null separated 00 terminated list
  269. LPBYTE lpBuffer, // pointer to buffer
  270. DWORD cBufSize, // size of buffer
  271. LPDWORD lpnEntriesRead, // number of names returned
  272. LPDWORD lpcbTotalAvailable // number of bytes available
  273. );
  274. UINT WINAPI
  275. NDdeTrustedShareEnumW (
  276. LPWSTR lpszServer, // server to execute on ( NULL for local )
  277. UINT nLevel, // 0 for null separated 00 terminated list
  278. LPBYTE lpBuffer, // pointer to buffer
  279. DWORD cBufSize, // size of buffer
  280. LPDWORD lpnEntriesRead, // number of names returned
  281. LPDWORD lpcbTotalAvailable // number of bytes available
  282. );
  283. /*
  284. Convert error code to string value
  285. */
  286. UINT WINAPI
  287. NDdeGetErrorStringA (
  288. UINT uErrorCode, // Error code to get string for
  289. LPSTR lpszErrorString, // buffer to hold error string
  290. DWORD cBufSize // sizeof buffer
  291. );
  292. UINT WINAPI
  293. NDdeGetErrorStringW (
  294. UINT uErrorCode, // Error code to get string for
  295. LPWSTR lpszErrorString, // buffer to hold error string
  296. DWORD cBufSize // sizeof buffer
  297. );
  298. /*
  299. Validate share name format
  300. */
  301. BOOL WINAPI
  302. NDdeIsValidShareNameA (
  303. LPSTR shareName
  304. );
  305. BOOL WINAPI
  306. NDdeIsValidShareNameW (
  307. LPWSTR shareName
  308. );
  309. /*
  310. Validate application/topic list format
  311. */
  312. BOOL WINAPI
  313. NDdeIsValidAppTopicListA (
  314. LPSTR targetTopic
  315. );
  316. BOOL WINAPI
  317. NDdeIsValidAppTopicListW (
  318. LPWSTR targetTopic
  319. );
  320. #ifdef UNICODE
  321. #define NDdeShareAdd NDdeShareAddW
  322. #define NDdeShareDel NDdeShareDelW
  323. #define NDdeSetShareSecurity NDdeSetShareSecurityW
  324. #define NDdeGetShareSecurity NDdeGetShareSecurityW
  325. #define NDdeShareEnum NDdeShareEnumW
  326. #define NDdeShareGetInfo NDdeShareGetInfoW
  327. #define NDdeShareSetInfo NDdeShareSetInfoW
  328. #define NDdeGetErrorString NDdeGetErrorStringW
  329. #define NDdeIsValidShareName NDdeIsValidShareNameW
  330. #define NDdeIsValidAppTopicList NDdeIsValidAppTopicListW
  331. #define NDdeSetTrustedShare NDdeSetTrustedShareW
  332. #define NDdeGetTrustedShare NDdeGetTrustedShareW
  333. #define NDdeTrustedShareEnum NDdeTrustedShareEnumW
  334. #else
  335. #define NDdeShareAdd NDdeShareAddA
  336. #define NDdeShareDel NDdeShareDelA
  337. #define NDdeSetShareSecurity NDdeSetShareSecurityA
  338. #define NDdeGetShareSecurity NDdeGetShareSecurityA
  339. #define NDdeShareEnum NDdeShareEnumA
  340. #define NDdeShareGetInfo NDdeShareGetInfoA
  341. #define NDdeShareSetInfo NDdeShareSetInfoA
  342. #define NDdeGetErrorString NDdeGetErrorStringA
  343. #define NDdeIsValidShareName NDdeIsValidShareNameA
  344. #define NDdeIsValidAppTopicList NDdeIsValidAppTopicListA
  345. #define NDdeSetTrustedShare NDdeSetTrustedShareA
  346. #define NDdeGetTrustedShare NDdeGetTrustedShareA
  347. #define NDdeTrustedShareEnum NDdeTrustedShareEnumA
  348. #endif
  349. #ifdef __cplusplus
  350. }
  351. #endif /* __cplusplus */
  352. #include <poppack.h>
  353. #endif /* _INC_NDDEAPI */