Thread: WININET HttpOpenRequest Help

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    WININET HttpOpenRequest Help

    I am trying to check if a port is open using the internet site ismyportopen.com, i seem to get to the function HttpOpenRequest working with this get request...

    g_hHttpRequest = HttpOpenRequest(g_hNetSession, "GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=80&t=1406357001803" , "", "HTTP/1.1", "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
    if(g_hHttpRequest == NULL)
    printf("HttpOpenRequest() returned NULL %d\n",GetLastError());

    GetlastError returns
    ERROR_INVALID_PARAMETER
    87 (0x57)
    The parameter is incorrect.

    the string was captured with a chrome http logger so i dont know how its giving me an error..

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    HttpOpenRequest function (Windows)
    Notice how everything is a TSTR

    Using Generic-Text Mappings
    You need to use _TEXT("foo") in place of all your "foo" strings.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Now ive got this

    g_hNetSession = InternetConnect(g_hRoot, _TEXT("ismyportopen.com"), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);

    g_hHttpRequest = HttpOpenRequest(g_hNetSession, _TEXT("GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=5050&t=140635700180 3"), "", _TEXT("HTTP/1.1"), "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);

    But still have the same issue,btw thanks for replying...
    Last edited by Anddos; 07-26-2014 at 09:18 AM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Sure, and what about these as well?

    _TEXT("")
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Those are set to NULL instead now

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Still cant get it working

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    g_hHttpRequest = HttpOpenRequest(g_hNetSession, _TEXT("GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=5050&t=140635700180 3"), "", _TEXT("HTTP/1.1"), "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
    > Those are set to NULL instead now

    Are you even reading the manual page?
    Parameters

    hConnect [in]
    A handle to an HTTP session returned by InternetConnect.

    lpszVerb [in]
    A pointer to a null-terminated string that contains the HTTP verb to use in the request. If this parameter is NULL, the function uses GET as the HTTP verb.

    lpszObjectName [in]
    A pointer to a null-terminated string that contains the name of the target object of the specified HTTP verb. This is generally a file name, an executable module, or a search specifier.

    lpszVersion [in]
    A pointer to a null-terminated string that contains the HTTP version to use in the request. Settings in Internet Explorer will override the value specified in this parameter.
    If this parameter is NULL, the function uses an HTTP version of 1.1 or 1.0, depending on the value of the Internet Explorer settings.
    Where do you see in this that the 3rd parameter can be NULL ?

    You might also wonder why you think the empty string is a good idea as well.

    > Still cant get it working
    That's a shame.
    But you need to post your latest code and error messages if you want a better response.
    Ideally, code that will compile and run. A few lines barely cuts it, and 1-line posts of "it doesn't work" are a complete waste of space.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wininet
    By jopp3 in forum C Programming
    Replies: 0
    Last Post: 04-29-2007, 09:27 AM
  2. My tut on WinINet...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 04-24-2007, 11:33 AM
  3. HttpOpenRequest lplpszAcceptTypes
    By abachler in forum Networking/Device Communication
    Replies: 3
    Last Post: 04-17-2007, 01:16 PM
  4. wininet/gcc - how to?
    By cdave in forum Windows Programming
    Replies: 3
    Last Post: 11-15-2005, 06:10 PM
  5. Error code 1813 after calling HttpOpenRequest
    By jmd15 in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-10-2005, 10:37 AM