How to pass arrays in COMDCOM:

zhaozj2021-02-17  50

Because the COM / DCOM object is not running in the client program (except for the COM object, even if so, in order to unify the interface, the inner process COM must not pass the pointer), and all the programs in Win32 have their own independent 2GB The memory space, the program and the program transmits pointer (memory address) are meaningless, and a large number of data such as arrays, strings is allocated in the program, and then use the pointer to add internal deployment. If you access data, how do you pass in the COM / DCOM object? A new variable Variant is introduced in Win32, and an array can be passed through Variant. Specific implementation method, Delphi is implemented as: a Server (COM / DCOM program): procedure ttestdcom.send4 (size: integer; d1: olevariant); type tdata = array [0..999] of byte; var data: tdata I: integer; begin for i: = 0 to size-1 do begin data [i]: = D1 [i]; end; end; cleIne: var D1: olevariant; begin D1: = varraycreate ([0,99 ], varbyte); {D1 [1]: = 45; .... // Deposit value into D1} s.send4 (99, d1); // s is the TestDcom object END;

转载请注明原文地址:https://www.9cbs.com/read-30398.html

New Post(0)