Dimitris Kounalakis

Member since: Friday, 30 December 2016
Last login: 13 hours 30 minutes ago
Profile viewed: 95 views

No Rank
Points: 0

Dimitris Kounalakis replied to the topic 'Winhttp in Delphi tokyo 10.2.3' in the forum. 3 months ago

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.

Read More...

Dimitris Kounalakis replied to the topic 'Winhttp in Delphi tokyo 10.2.3' in the forum. 3 months ago

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;
....
siz:=0; down:=0;
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');

Read More...

Dimitris Kounalakis replied to the topic 'Winhttp in Delphi tokyo 10.2.3' in the forum. 3 months ago

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.
but....
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......

Read More...

Dimitris Kounalakis replied to the topic 'Winhttp in Delphi tokyo 10.2.3' in the forum. 3 months ago

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

Read More...

Dimitris Kounalakis created a new topic ' Winhttp in Delphi tokyo 10.2.3' in the forum. 4 months ago

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.....

Read More...