jwalmmsg.pas 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Messages 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: lmmsg.h, released November 2001. The original Pascal }
  9. { code is: LmMsg.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 JwaLmMsg;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmmsg.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinType;
  51. //
  52. // Function Prototypes
  53. //
  54. function NetMessageNameAdd(servername, msgname: LPCWSTR): NET_API_STATUS; stdcall;
  55. {$EXTERNALSYM NetMessageNameAdd}
  56. function NetMessageNameEnum(servername: LPCWSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries: LPDWORD; resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  57. {$EXTERNALSYM NetMessageNameEnum}
  58. function NetMessageNameGetInfo(servername, msgname: LPCWSTR; level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  59. {$EXTERNALSYM NetMessageNameGetInfo}
  60. function NetMessageNameDel(servername, msgname: LPCWSTR): NET_API_STATUS; stdcall;
  61. {$EXTERNALSYM NetMessageNameDel}
  62. function NetMessageBufferSend(servername, msgname, fromname: LPCWSTR; buf: LPBYTE; buflen: DWORD): NET_API_STATUS; stdcall;
  63. {$EXTERNALSYM NetMessageBufferSend}
  64. //
  65. // Data Structures
  66. //
  67. type
  68. _MSG_INFO_0 = record
  69. msgi0_name: LPWSTR;
  70. end;
  71. {$EXTERNALSYM _MSG_INFO_0}
  72. MSG_INFO_0 = _MSG_INFO_0;
  73. {$EXTERNALSYM MSG_INFO_0}
  74. PMSG_INFO_0 = ^MSG_INFO_0;
  75. {$EXTERNALSYM PMSG_INFO_0}
  76. LPMSG_INFO_0 = ^MSG_INFO_0;
  77. {$EXTERNALSYM LPMSG_INFO_0}
  78. TMsgInfo0 = MSG_INFO_0;
  79. PMsgInfo0 = PMSG_INFO_0;
  80. _MSG_INFO_1 = record
  81. msgi1_name: LPWSTR;
  82. msgi1_forward_flag: DWORD;
  83. msgi1_forward: LPWSTR;
  84. end;
  85. {$EXTERNALSYM _MSG_INFO_1}
  86. MSG_INFO_1 = _MSG_INFO_1;
  87. {$EXTERNALSYM MSG_INFO_1}
  88. PMSG_INFO_1 = ^MSG_INFO_1;
  89. {$EXTERNALSYM PMSG_INFO_1}
  90. LPMSG_INFO_1 = ^MSG_INFO_1;
  91. {$EXTERNALSYM LPMSG_INFO_1}
  92. TMsgInfo1 = MSG_INFO_1;
  93. PMsgInfo1 = PMSG_INFO_1;
  94. //
  95. // Special Values and Constants
  96. //
  97. //
  98. // Values for msgi1_forward_flag.
  99. //
  100. const
  101. MSGNAME_NOT_FORWARDED = 0; // Name not forwarded
  102. {$EXTERNALSYM MSGNAME_NOT_FORWARDED}
  103. MSGNAME_FORWARDED_TO = $04; // Name forward to remote station
  104. {$EXTERNALSYM MSGNAME_FORWARDED_TO}
  105. MSGNAME_FORWARDED_FROM = $10; // Name forwarded from remote station
  106. {$EXTERNALSYM MSGNAME_FORWARDED_FROM}
  107. implementation
  108. {$IFDEF DYNAMIC_LINK}
  109. var
  110. _NetMessageNameAdd: Pointer;
  111. function NetMessageNameAdd;
  112. begin
  113. GetProcedureAddress(_NetMessageNameAdd, netapi32, 'NetMessageNameAdd');
  114. asm
  115. MOV ESP, EBP
  116. POP EBP
  117. JMP [_NetMessageNameAdd]
  118. end;
  119. end;
  120. var
  121. _NetMessageNameEnum: Pointer;
  122. function NetMessageNameEnum;
  123. begin
  124. GetProcedureAddress(_NetMessageNameEnum, netapi32, 'NetMessageNameEnum');
  125. asm
  126. MOV ESP, EBP
  127. POP EBP
  128. JMP [_NetMessageNameEnum]
  129. end;
  130. end;
  131. var
  132. _NetMessageNameGetInfo: Pointer;
  133. function NetMessageNameGetInfo;
  134. begin
  135. GetProcedureAddress(_NetMessageNameGetInfo, netapi32, 'NetMessageNameGetInfo');
  136. asm
  137. MOV ESP, EBP
  138. POP EBP
  139. JMP [_NetMessageNameGetInfo]
  140. end;
  141. end;
  142. var
  143. _NetMessageNameDel: Pointer;
  144. function NetMessageNameDel;
  145. begin
  146. GetProcedureAddress(_NetMessageNameDel, netapi32, 'NetMessageNameDel');
  147. asm
  148. MOV ESP, EBP
  149. POP EBP
  150. JMP [_NetMessageNameDel]
  151. end;
  152. end;
  153. var
  154. _NetMessageBufferSend: Pointer;
  155. function NetMessageBufferSend;
  156. begin
  157. GetProcedureAddress(_NetMessageBufferSend, netapi32, 'NetMessageBufferSend');
  158. asm
  159. MOV ESP, EBP
  160. POP EBP
  161. JMP [_NetMessageBufferSend]
  162. end;
  163. end;
  164. {$ELSE}
  165. function NetMessageNameAdd; external netapi32 name 'NetMessageNameAdd';
  166. function NetMessageNameEnum; external netapi32 name 'NetMessageNameEnum';
  167. function NetMessageNameGetInfo; external netapi32 name 'NetMessageNameGetInfo';
  168. function NetMessageNameDel; external netapi32 name 'NetMessageNameDel';
  169. function NetMessageBufferSend; external netapi32 name 'NetMessageBufferSend';
  170. {$ENDIF DYNAMIC_LINK}
  171. end.