CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Memory leak?

  1. #1
    Join Date
    Jun 1999
    Posts
    9

    Memory leak?

    Hi all,

    I need to use FormatMessage function in my program and i call it like this:

    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
    FORMAT_MESSAGE_FROM_HMODULE,
    Model, // Handle of the dll file
    EventID,
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR) lpMessage, // array of char[2048]
    2048,
    (char**) strInsert);



    However, there is runtime error when executing this function (program halt) and I think there may be problem for the last parameter. It is the array of string char[30][512]. I don't know if the mapping works or not. Anyone can tell me how to add insertion string to the message when using FormatMessage?

    Thank a lot

    Herman Lee


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Memory leak?

    The last parameter must be a pointer to a va_list (see stdarg.h or vararg.h and how C handles varing number of parameters), or it must be an array of 32-bit values. If it is an array of unsigned longs, the FORMAT_MESSAGE_ARGUMENT_ARRAY flag must be specified.

    All of this info is in the on-line help.

    Regards,

    Paul McKenzie


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured