Home > Software engineering >  For help: COM connection point (the callback) to the structure parameters?
For help: COM connection point (the callback) to the structure parameters?

Time:09-20


Overall description:
ATL COM components, c # interface,
C # call COM component for business processing, c + + callback to c # interface,
Basic connection, the callback parameter if is ordinary parameters, such as LONG *, sure
But if is structural,
 hr=pConnection - & gt; Invoke (1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, & amp; Params, & amp; VarResult, NULL, NULL); 

This sentence will return failure: there is a parameter is invalid

IDL:
 
Struct Point
{
LONG x, y;
};

Struct PROPERTY
{
Struct Point pt;

FLOAT x;
FLOAT y;
FLOAT z;
FLOAT f;
};

Dispinterface IEvents
{
Methods:
[id (1)] HRESULT GetProperty ([in] the int index, [in, out] struct PROPERTY * prop);
};


Considering the structure behind will often change or expand, so don't want to write the parameters start each one with a pointer to the callback:)

Similar problems to the others early also asked the didn't get the solution:
http://bbs.csdn.net/topics/390592325

CodePudding user response:

C # are not ripe, is purely personal opinion

Struct _tagMySruct_t
{
Int cbSize;
LONG...
} MYSTRUCT, * LPSTRUCT;

Pass a pointer to void * and coercion

CodePudding user response:

reference 1st floor zgl7903 response:
are not familiar with c #, is purely personal opinion

Struct _tagMySruct_t
{
Int cbSize;
LONG...
} MYSTRUCT, * LPSTRUCT;

Pass a pointer to void *, and then cast


I in the IDL defines the structure, so that c # and c + + structure easy to exchange,
Or c # to define your own structure, describe the more complicated than the c + +,

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, then b.t xt renamed bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!

CodePudding user response:

reference zhao4zhong1 reply: 3/f
don't do A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, then b.t xt renamed bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!


You let a person very speechless, really
1. com is a standard specification, application is very wide also, it is support across languages, now I met a little difficulty was to give up, not the developers style
2. What do you think is read and write files can meet the general requirements, but if they are of high real time capability, the demand of the large amount of data, text, speaking, reading and writing is not suitable
3. Realize the text communication, also come up with a memory file, development efficiency is not high, the late in the long run, I think is not the best choice,

CodePudding user response:

Don't use structure, using the method of pass SAFEARRAY array

CodePudding user response:

COM support across languages?

Can cross
Apple] [
C51
DOS
Linux
Android
IOS
VxWorks
Arduino
.
?

Don't talk about efficiency without profiler!! Especially in the cloud computing, virtual machine, simulator, CUDA, multi-core, multistage cache, command line, a variety of storage media,... In the age of flying!

CodePudding user response:

reference 5 floor oyljerry reply:
no structure, by pass SAFEARRAY array


The c # the end also according to the array access bai, poor's readability, as more and more complex structure,

Look into BSTR is also available online, do not know is said with a BSTR when memory block data transfer (BSTR itself size), or into a real string description: format?

I use the method of the others on the net, the whole results serialized into the VT structure, error is returned, I don't know is an error occurred when processing parameters, the COM server itself or the client # error when converted into c # of the available data,,,

CodePudding user response:

reference 5 floor oyljerry reply:
no structure, by pass SAFEARRAY array


I call in c # COM GetXXX or SetXXX methods, use of the structure is no problem, proves the COM in dealing with structural parameters is can handle it,
Is the callback part structure has a problem,
Don't know is not used, or MS implementation not ready,,,

CodePudding user response:

After another wall bumps bumps bumps

CodePudding user response:

Structure restructuring as a separate COM object is solved, return a pointer to the COM object interfaces variation value, then the c # the COM object interfaces variant pointer cast to the actual type of COM object pointer

CodePudding user response:

references to the tenth floor WWWFFFHHH response:
structure restructuring as a separate COM object is solved, the return value is a COM object interface pointer variation, then the c # the COM object interfaces variant pointer type cast to the actual COM object pointer


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related