Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WinInet troubleshooting
Message
From
07/04/2000 13:27:50
 
 
To
07/04/2000 10:48:41
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00356440
Message ID:
00356979
Views:
43
>>>>>and here is the C function declaration:
>>>>>
>>>>>
BOOL InternetSetOption(
>>>>>    IN HINTERNET hInternet,
>>>>>    IN DWORD dwOption,
>>>>>    IN LPVOID lpBuffer,
>>>>>    IN DWORD dwBufferLength
>>>>>);
>>>>>
>>>>>
>>>>
>>>>Eric, see my reply to the previous question; try allocating a static block and passing the pointer to the block by reference - structures don't like to be moved about.
>>>>
>>>
>>>I will try that whe I get back to that machine.. but where's a struture?
>>
>>The LPVOID is suspicious - it's either a pointer to a function entrypointy, or to something of indefinite shape and size and type. It's IN, so it shouldn't be getting set, but I'd want to know more about it's construction...
>
>Correct me if this sounds wrong, but I think that its void because its type is not known? IOW, the InternetSetOption is a little like DBSETPROP, in that the second parameter is the name of the option to be set, and the 3rd is the value to set it to. Depending on the value of the second parameter, the third might be a string, an integer, or whatever. Sound good?
>

Yep - that's a LPVOID - it points to something, but it doesn't exactly know what it is ahead of time.

>BTW, if I pass an actual pointer that I got with Heap.Alloc, I would have to change the declare to reflect an integer, right? I tried, and got the same error I was getting before: 12018- the supplied handle is the wrong type for the requested operation.
>

Correct - the return from oHeap.Alloc is a pointer to ann allocated block in the heap of at least the size requested; it's passed as an INTEGER (not INTEGER @); if the function were possibly passing back a value that you needed to pick up from the return (ie something that handed back a pointer to some bock of RAM somewhere) you'd pass by ref in the function call. the declare would look like:

DECLARE SHORT InternetSetOption IN WinInet INTEGER, INTEGER, INTEGER, INTEGER

passing the pointer to the block from oHeap.Alloc(), and populating it by building whatever you need in a string and using CopyTo.

>Man, this is wierd. I changed the DECLARE to pass an integer for the option setting, and changed the option to one that required an integer (INTERNET_OPTION_CONNECT_TIMEOUT), and the function works fine. But for a function that requires a string, I get the "handle" error. Just to see, I changed the string parameter to pass by value, and it made no difference. If nothing else, it seems I am getting the wrong error number for what is really happening.

Just for grins, try the declare above, and try the following for lpBuffer:

nBuffPtr = oHeap.AllocString('whatever the string is')
nBuffLen = oHeap.SizeOfBlock(nBuffPtr)-1

and pass nBuffPtr and nBuffLen as the third and fourth parameters respectively.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform