The function CAM_GrabImage (var devId: WideString; The out imageData: Pointer; The out imageSize: Int64; The out imageWidth: Integer; The out imageHeight: Integer) : Integer; Cdecl;
Written in Delphi program calls the imageData returns the normal pointer,
In c + + call imageData address turned out to be null, when the other parameters all return,
Somebody in and solve a similar situation?
Here is called C code, without exception, is imageData in the debug time is null, and when the entered the initial address, after the run becomes null,
Dllfun typedef __cdecl int (*) (char * devId, char * imageData, long * imageSize, imageWidth int * and an int * imageHeight);
Result=CAM_GrabImage (devId, imageData, imageSize, imageWidth, imageHeight);
Delphi
ImageData: Pointer I tried PChar
C
Char * void * are tried,
Results, are written in Delphi code calls the DLL returned to normal, C calls the same DLL, abnormal,
Please feel free to comment, thank you,
CodePudding user response:
ImageData: the inside of the Pointer to the data is X, YBut not a variable,
CodePudding user response:
Pointer is a Pointer type, coordinate is a TPoint structure, the out keyword modified parameters can only accept the output value, can't input, the corresponding Char *, PChar Pointer corresponding void * no problem, but the imageData may be Delphi is special type of object, if it is, usually cannot be used to the C/C + + DLL pass parameters should use basic types or structure of general type,CodePudding user response:
The function CAM_GrabImage (var devId: WideString; The out imageData: Pointer; The out imageSize: Int64; The out imageWidth: Integer; The out imageHeight: Integer) : Integer; Cdecl;And
Dllfun typedef __cdecl int (*) (char * devId, char * imageData, long * imageSize, imageWidth int * and an int * imageHeight);
In ah,
Should be first WideString would *, var devId: WideString should be would be * *, secondly should use long long or __int64 Int64, in addition all out parameters are changed, to preach references,
Dllfun typedef __cdecl int (*) (would be * * devId, char * * imageData, long long * imageSize, imageWidth int * and an int * imageHeight);
CodePudding user response:
Parameters you have any question, directly using the pointer noIf not you try changing a way of parameter passing
CodePudding user response:
I has always been defined as a string or Pchar Pwidechar, haven't tried with string, directly widestringCodePudding user response:
The