home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / nddeapi.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  15KB  |  401 lines

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