jwalmremutl.pas 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Remote API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: lmremutl.h, released November 2001. The original Pascal}
  9. { code is: LmRemUtl.pas, released Februari 2002. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaLmRemUtl.pas,v 1.10 2005/09/07 09:54:54 marquardt Exp $
  43. {$IFNDEF JWA_INCLUDEMODE}
  44. unit JwaLmRemUtl;
  45. {$WEAKPACKAGEUNIT}
  46. {$I jediapilib.inc}
  47. interface
  48. uses
  49. JwaWindows, JwaLmCons;
  50. {$ENDIF !JWA_INCLUDEMODE}
  51. {$IFDEF JWA_INTERFACESECTION}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT '#include "lmremutl.h"'}
  54. {$HPPEMIT ''}
  55. //
  56. // Type Definitions
  57. //
  58. type
  59. {$IFDEF DESC_CHAR_UNICODE}
  60. DESC_CHAR = WCHAR;
  61. {$EXTERNALSYM DESC_CHAR}
  62. {$ELSE}
  63. DESC_CHAR = Char;
  64. {$EXTERNALSYM DESC_CHAR}
  65. {$ENDIF DESC_CHAR_UNICODE}
  66. TDescChar = DESC_CHAR;
  67. LPDESC = ^DESC_CHAR;
  68. {$EXTERNALSYM LPDESC}
  69. PDesc = LPDESC;
  70. //
  71. // Function Prototypes
  72. //
  73. function NetRemoteTOD(UncServerName: LPCWSTR; var BufferPtr: LPBYTE): NET_API_STATUS; stdcall;
  74. {$EXTERNALSYM NetRemoteTOD}
  75. function NetRemoteComputerSupports(UncServerName: LPCWSTR; OptionsWanted: DWORD; OptionsSupported: LPDWORD): NET_API_STATUS; stdcall;
  76. {$EXTERNALSYM NetRemoteComputerSupports}
  77. {$IFDEF SUPPORTS_VARARGS}
  78. // mvb Delphi 6 and up only (because of the varargs)
  79. function RxRemoteApi(ApiNumber: DWORD; UncServerName: LPCWSTR; ParmDescString, DataDesc16, DataDesc32, DataDescSmb,
  80. AuxDesc16, AuxDesc32, AuxDescSmb: LPDESC; Flags: DWORD{, ...}): NET_API_STATUS; cdecl; varargs;
  81. {$EXTERNALSYM RxRemoteApi}
  82. {$ENDIF SUPPORTS_VARARGS}
  83. //
  84. // Data Structures
  85. //
  86. type
  87. _TIME_OF_DAY_INFO = record
  88. tod_elapsedt: DWORD;
  89. tod_msecs: DWORD;
  90. tod_hours: DWORD;
  91. tod_mins: DWORD;
  92. tod_secs: DWORD;
  93. tod_hunds: DWORD;
  94. tod_timezone: LONG;
  95. tod_tinterval: DWORD;
  96. tod_day: DWORD;
  97. tod_month: DWORD;
  98. tod_year: DWORD;
  99. tod_weekday: DWORD;
  100. end;
  101. {$EXTERNALSYM _TIME_OF_DAY_INFO}
  102. TIME_OF_DAY_INFO = _TIME_OF_DAY_INFO;
  103. {$EXTERNALSYM TIME_OF_DAY_INFO}
  104. PTIME_OF_DAY_INFO = ^TIME_OF_DAY_INFO;
  105. {$EXTERNALSYM PTIME_OF_DAY_INFO}
  106. LPTIME_OF_DAY_INFO = ^TIME_OF_DAY_INFO;
  107. {$EXTERNALSYM LPTIME_OF_DAY_INFO}
  108. TTimeOfDayInfo = TIME_OF_DAY_INFO;
  109. PTimeOfDayInfo = PTIME_OF_DAY_INFO;
  110. //
  111. // Special Values and Constants
  112. //
  113. //
  114. // Mask bits for use with NetRemoteComputerSupports:
  115. //
  116. const
  117. SUPPORTS_REMOTE_ADMIN_PROTOCOL = $00000002;
  118. {$EXTERNALSYM SUPPORTS_REMOTE_ADMIN_PROTOCOL}
  119. SUPPORTS_RPC = $00000004;
  120. {$EXTERNALSYM SUPPORTS_RPC}
  121. SUPPORTS_SAM_PROTOCOL = $00000008;
  122. {$EXTERNALSYM SUPPORTS_SAM_PROTOCOL}
  123. SUPPORTS_UNICODE = $00000010;
  124. {$EXTERNALSYM SUPPORTS_UNICODE}
  125. SUPPORTS_LOCAL = $00000020;
  126. {$EXTERNALSYM SUPPORTS_LOCAL}
  127. SUPPORTS_ANY = DWORD($FFFFFFFF);
  128. {$EXTERNALSYM SUPPORTS_ANY}
  129. //
  130. // Flag bits for RxRemoteApi:
  131. //
  132. const
  133. NO_PERMISSION_REQUIRED = $00000001; // set if use NULL session
  134. {$EXTERNALSYM NO_PERMISSION_REQUIRED}
  135. ALLOCATE_RESPONSE = $00000002; // set if RxRemoteApi allocates response buffer
  136. {$EXTERNALSYM ALLOCATE_RESPONSE}
  137. USE_SPECIFIC_TRANSPORT = DWORD($80000000);
  138. {$EXTERNALSYM USE_SPECIFIC_TRANSPORT}
  139. {$ENDIF JWA_INTERFACESECTION}
  140. {$IFNDEF JWA_INCLUDEMODE}
  141. implementation
  142. uses
  143. JwaWinDLLNames;
  144. {$ENDIF !JWA_INCLUDEMODE}
  145. {$IFDEF JWA_IMPLEMENTATIONSECTION}
  146. // todo cdecl function so no dynamic linking for the time being...
  147. {$IFDEF SUPPORTS_VARARGS}
  148. function RxRemoteApi; external netapi32 name 'RxRemoteApi';
  149. {$ENDIF SUPPORTS_VARARGS}
  150. {$IFDEF DYNAMIC_LINK}
  151. var
  152. _NetRemoteTOD: Pointer;
  153. function NetRemoteTOD;
  154. begin
  155. GetProcedureAddress(_NetRemoteTOD, netapi32, 'NetRemoteTOD');
  156. asm
  157. MOV ESP, EBP
  158. POP EBP
  159. JMP [_NetRemoteTOD]
  160. end;
  161. end;
  162. var
  163. _NetRemoteComputerSupports: Pointer;
  164. function NetRemoteComputerSupports;
  165. begin
  166. GetProcedureAddress(_NetRemoteComputerSupports, netapi32, 'NetRemoteComputerSupports');
  167. asm
  168. MOV ESP, EBP
  169. POP EBP
  170. JMP [_NetRemoteComputerSupports]
  171. end;
  172. end;
  173. {$ELSE}
  174. function NetRemoteTOD; external netapi32 name 'NetRemoteTOD';
  175. function NetRemoteComputerSupports; external netapi32 name 'NetRemoteComputerSupports';
  176. {$ENDIF DYNAMIC_LINK}
  177. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  178. {$IFNDEF JWA_INCLUDEMODE}
  179. end.
  180. {$ENDIF !JWA_INCLUDEMODE}