I am using the example code from ObjectTextToBinary to load a control, but if the input string is more then 4096 then I get an Eparse Error error "Line too long on line 1".
I believe that this is a limitation with a maximum of 4096 bytes when creating Twriter inside ObjectTextToBinary.
How can I overcome this problem?
Thank you in advance
Thank you for the explanation. To be honest I had this problem again in the past with c calls to libraries and I did not understand this difference. I was believing that a pointer is just a pointer to the memory buffer, not to a memory that holds the address of the memory buffer.
Now I understand the documentation for the "pointer":
"A void pointer represents the address of a byte in memory. Such a pointer cannot be dereferenced, because no type information is associated with it. However, a void pointer can be cast to a typed pointer and then dereferenced"
I apologize for the trouble. Thank you again for your time.
I think I found the problem:
the following does not work, with all variables having garbage except variable down
but if I declare the pp as "pp:array[1..32768] of byte;" everything is OK
my app is 32bit and I am having windows 64bit. I believe it has to do with the size of the pointer type.
var pp:pointer; siz,down:dword;
if not WinHttpQueryDataAvailable(hRequest,@siz) then senderr('error');
if siz<8128 then pp:=allocMem(8196) else pp:=allocMem(siz+1);
if not WinHttpReadData(hRequest,pp,siz+1,@down) then senderr('error');
I try to test today the situation. I changed all cardinals to Dwords.
I followed the header declarations in winapi.winhttp and I noticed the following:
Just before calling the WinHttpReadData everything is OK in my debugging. After that nearly all variables are garbage.
a. I use a pointer from an allocmem of 8K as winhtttp docs suggest here even the needed size of the data as returned by WinHttpQueryDataAvailable is less than 300bytes.
b. The result from WinHttpReadData is true
I tried to change the winapi.winhttp and have the declaration from DELPHI 10.1 but even if I change it from notepad and Delphi IDE requests to reload it, the syntax is found incorrect during compile. Where is the header file that it is used during compile?
The one that I changed is in C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\win
I feel it is not a problem from the declaration anymore......
I fully agree with you, and the stdcall exists in 10.1
In 32bit VCL application, I I pass a pointer to a cardinal variable and I get unpredictable results
I noticed now that probably cardinal is not the same thing with longword for the compiler, so I will test it again....
thank you for your response
I found that my code from 10.1 can not be compiled in 10.2 when using the winhttp api
I noticed that there are changes in winapi.WinHttp in 10.2.3 : eg
function WinHttpQueryDataAvailable(hRequest: HINTERNET; lpdwNumberOfBytesAvailable: LPDWORD): BOOL; stdcall;
In 10.1 the same function is declared as:
function WinHttpQueryDataAvailable(hRequest: HInternet; var lpdwNumberofBytesAvailable): BOOL;
The problem is that using a DWORD variable and passing its pointer gives unpredictable results.....