jwalmremutl.pas 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. unit JwaLmRemUtl;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmremutl.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinType;
  51. //
  52. // Type Definitions
  53. //
  54. type
  55. {$IFDEF DESC_CHAR_UNICODE}
  56. DESC_CHAR = WCHAR;
  57. {$EXTERNALSYM DESC_CHAR}
  58. {$ELSE}
  59. DESC_CHAR = Char;
  60. {$EXTERNALSYM DESC_CHAR}
  61. {$ENDIF DESC_CHAR_UNICODE}
  62. TDescChar = DESC_CHAR;
  63. LPDESC = ^DESC_CHAR;
  64. {$EXTERNALSYM LPDESC}
  65. PDesc = LPDESC;
  66. //
  67. // Function Prototypes
  68. //
  69. function NetRemoteTOD(UncServerName: LPCWSTR; var BufferPtr: LPBYTE): NET_API_STATUS; stdcall;
  70. {$EXTERNALSYM NetRemoteTOD}
  71. function NetRemoteComputerSupports(UncServerName: LPCWSTR; OptionsWanted: DWORD; OptionsSupported: LPDWORD): NET_API_STATUS; stdcall;
  72. {$EXTERNALSYM NetRemoteComputerSupports}
  73. {$IFDEF SUPPORTS_VARARGS}
  74. // mvb Delphi 6 and up only (because of the varargs)
  75. function RxRemoteApi(ApiNumber: DWORD; UncServerName: LPCWSTR; ParmDescString, DataDesc16, DataDesc32, DataDescSmb,
  76. AuxDesc16, AuxDesc32, AuxDescSmb: LPDESC; Flags: DWORD{, ...}): NET_API_STATUS; cdecl; varargs;
  77. {$EXTERNALSYM RxRemoteApi}
  78. {$ENDIF SUPPORTS_VARARGS}
  79. //
  80. // Data Structures
  81. //
  82. type
  83. _TIME_OF_DAY_INFO = record
  84. tod_elapsedt: DWORD;
  85. tod_msecs: DWORD;
  86. tod_hours: DWORD;
  87. tod_mins: DWORD;
  88. tod_secs: DWORD;
  89. tod_hunds: DWORD;
  90. tod_timezone: LONG;
  91. tod_tinterval: DWORD;
  92. tod_day: DWORD;
  93. tod_month: DWORD;
  94. tod_year: DWORD;
  95. tod_weekday: DWORD;
  96. end;
  97. {$EXTERNALSYM _TIME_OF_DAY_INFO}
  98. TIME_OF_DAY_INFO = _TIME_OF_DAY_INFO;
  99. {$EXTERNALSYM TIME_OF_DAY_INFO}
  100. PTIME_OF_DAY_INFO = ^TIME_OF_DAY_INFO;
  101. {$EXTERNALSYM PTIME_OF_DAY_INFO}
  102. LPTIME_OF_DAY_INFO = ^TIME_OF_DAY_INFO;
  103. {$EXTERNALSYM LPTIME_OF_DAY_INFO}
  104. TTimeOfDayInfo = TIME_OF_DAY_INFO;
  105. PTimeOfDayInfo = PTIME_OF_DAY_INFO;
  106. //
  107. // Special Values and Constants
  108. //
  109. //
  110. // Mask bits for use with NetRemoteComputerSupports:
  111. //
  112. const
  113. SUPPORTS_REMOTE_ADMIN_PROTOCOL = $00000002;
  114. {$EXTERNALSYM SUPPORTS_REMOTE_ADMIN_PROTOCOL}
  115. SUPPORTS_RPC = $00000004;
  116. {$EXTERNALSYM SUPPORTS_RPC}
  117. SUPPORTS_SAM_PROTOCOL = $00000008;
  118. {$EXTERNALSYM SUPPORTS_SAM_PROTOCOL}
  119. SUPPORTS_UNICODE = $00000010;
  120. {$EXTERNALSYM SUPPORTS_UNICODE}
  121. SUPPORTS_LOCAL = $00000020;
  122. {$EXTERNALSYM SUPPORTS_LOCAL}
  123. SUPPORTS_ANY = DWORD($FFFFFFFF);
  124. {$EXTERNALSYM SUPPORTS_ANY}
  125. //
  126. // Flag bits for RxRemoteApi:
  127. //
  128. const
  129. NO_PERMISSION_REQUIRED = $00000001; // set if use NULL session
  130. {$EXTERNALSYM NO_PERMISSION_REQUIRED}
  131. ALLOCATE_RESPONSE = $00000002; // set if RxRemoteApi allocates response buffer
  132. {$EXTERNALSYM ALLOCATE_RESPONSE}
  133. USE_SPECIFIC_TRANSPORT = DWORD($80000000);
  134. {$EXTERNALSYM USE_SPECIFIC_TRANSPORT}
  135. implementation
  136. // todo cdecl function so no dynamic linking for the time being...
  137. {$IFDEF SUPPORTS_VARARGS}
  138. function RxRemoteApi; external netapi32 name 'RxRemoteApi';
  139. {$ENDIF SUPPORTS_VARARGS}
  140. {$IFDEF DYNAMIC_LINK}
  141. var
  142. _NetRemoteTOD: Pointer;
  143. function NetRemoteTOD;
  144. begin
  145. GetProcedureAddress(_NetRemoteTOD, netapi32, 'NetRemoteTOD');
  146. asm
  147. MOV ESP, EBP
  148. POP EBP
  149. JMP [_NetRemoteTOD]
  150. end;
  151. end;
  152. var
  153. _NetRemoteComputerSupports: Pointer;
  154. function NetRemoteComputerSupports;
  155. begin
  156. GetProcedureAddress(_NetRemoteComputerSupports, netapi32, 'NetRemoteComputerSupports');
  157. asm
  158. MOV ESP, EBP
  159. POP EBP
  160. JMP [_NetRemoteComputerSupports]
  161. end;
  162. end;
  163. {$ELSE}
  164. function NetRemoteTOD; external netapi32 name 'NetRemoteTOD';
  165. function NetRemoteComputerSupports; external netapi32 name 'NetRemoteComputerSupports';
  166. {$ENDIF DYNAMIC_LINK}
  167. end.