Thread: HttpOpenRequest lplpszAcceptTypes

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007

    HttpOpenRequest lplpszAcceptTypes

    Im trying to implement a simple update function, but I cant get this function to work with binary files. Can someone please post a snippet of code showing how to implement this?

    I have tried recasting the lplpszAcceptTypes every which way but loose, and VC keeps complaining about it. A search of the net shows that im nto alone in this problem, but turns up no solution as yet.

    Currently I have it implmented as such:

    const char szMIME[] = "image/bmp";
    LPSTR MIME[3];

    lpMIME = &MIME[0];

    /* snip code that copies szMIME into allocated memory pointed to by MIME[0]; */

    hRequest = HttpOpenRequest( hConnection , NULL , (char *)&szFile , NULL , NULL , (LPSTR *)lpMIME/*image/bmp*/ , INTERNET_FLAG_KEEP_CONNECTION || INTERNET_FLAG_PRAGMA_NOCACHE , 0 );
    Last edited by abachler; 04-16-2007 at 03:25 PM. Reason: add code

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    OK, I feel dumb now, all i needed to do was recast the lpMIME as (char **)lpMIME and it accepted it.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Of course casting can be used to cover up a multitude of sins, which don't involve reading the manual.

    Do you know the difference between | and || ?

    > (char *)&szFile
    Perhaps if you dropped the &, you could drop the cast as well?
    I'm assuming from your use of hungarian notation that this is an array?

    > (LPSTR *)lpMIME
    To quote the manual page
    Quote Originally Posted by msdn
    [in] A pointer to a null-terminated array of strings that indicates media types accepted by the client. If this parameter is NULL, no types are accepted by the client. Servers generally interpret a lack of accept types to indicate that the client accepts only documents of type "text/*" (that is, only text documents—no pictures or other binary files). For more information and a list of valid media types, see
    How is your array terminated with a NULL pointer?
    char *szMIME[] = {
    Then perhaps you can pass szMime as a parameter without any casting, and without any copying?
    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.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    You cant pass the array directly , the function call requires a pointer to an array of pointers, not a single pointer to a string. In any case, the casting was the problem, since I already had the array of pointers set up properly. The compiler just didnt want to accept the conversion from const char ** to char **

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error code 1813 after calling HttpOpenRequest
    By jmd15 in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-10-2005, 10:37 AM