Scrive Arno Garrels <[EMAIL PROTECTED]>:

> Maurizio Lotauro wrote:
> > Scrive Arno Garrels <[EMAIL PROTECTED]>:

[...]

> >> Don't you allocate the memory before passing the pointer?
> > 
> > No, should I? The docs don't seems very clear to me. Have look at
> 
> I think you should, like with most DLL calls that return a variable
> amount of data. There's also lpdwProxyHostNameLength. Mostly when you
> call such functions with a nil pointer and/or zero length 
> the function will return the length of the buffer that the caller
> has to allocate before calling it a second time with
> a non-nil pointer to an allocated piece of memory.

I know, this is how I do for example the second call of InternetQueryOption.

> Is this not working you?

No. I redo the test based on the sample found in the following link:

http://msdn2.microsoft.com/en-us/library/aa383910.aspx

As you see a buffer is allocated:

  char proxyBuffer[1024];
  char* proxy = proxyBuffer;
  ZeroMemory( proxy, 1024 );
  DWORD dwProxyHostNameLength = 1024;

I translated so:

const
  PROXY_BUFFER_LENGTH = 1024;
var
  buffer: array[0..PROXY_BUFFER_LENGTH - 1] of Char;
  proxy: PChar;
  buflen: Longword;
begin
  proxy := @buffer[0];
  FillChar(buffer, PROXY_BUFFER_LENGTH, #0);
  buflen := PROXY_BUFFER_LENGTH;
  
At this point Pointer(proxy) has the same value of @buffer[0].
After the InternetGetProxyInfo call (notice that for the test I declared the
last two parameters as "var" instead "out") Pointer(proxy) is changed! And of
course buffer is still filled with zero.
Notice that in the C sample at the end proxy and not proxyBuffer is used to show
the result.
It could be very interesting if someone can try the C code and check the content
of proxyBuffer.

This function is very strange. First the JSProxy.dll "must be linked dynamically
at runtime". The last two parameters of the function are declare as out, and
noticed that lplpszProxyHostName is a pointer of pointer, not a pointer as 
usual.

It is a quite unclear situation, isn't it?


Bye, Maurizio.

----------------------------------------------------
This mail has been sent using Alpikom webmail system
http://www.alpikom.it

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to