How to quickly view the constant values required by the standard-dll API functions?-VBForums
Results 1 to 9 of 9

Thread: How to quickly view the constant values required by the standard-dll API functions?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2012
    Posts
    814

    How to quickly view the constant values required by the standard-dll API functions?

    The trick helped me solve a very important problem about winmm.dll (thank you, The trick), he gave me a code snippet.

    Code:
        tIOInfo.fccIOProc = FOURCC_MEM
        tIOInfo.pchBuffer = VarPtr(bBuffer(0))
        tIOInfo.cchBuffer = UBound(bBuffer) + 1
    
        hFile = mmioOpen(vbNullString, tIOInfo, MMIO_READ)
    But I didn't know what the value of FOURCC_MEM is? I'd been searching the internet for a few hours without finding the value of this constant. I found mmsystem.h later and checked how this constant was defined in mmsystem.h. Finally, of course, the trick told me the answer.

    This thing reminds me of a question, when we reference a standard-dll, how to quickly view constant values required by its API functions? Is there any tool to do the similar work?
    Last edited by dreammanor; Jan 10th, 2018 at 05:37 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,091

    Re: How to quickly view the constant values required by the standard-dll API function

    Quote Originally Posted by dreammanor View Post
    Is there any tool to do the similar work?
    The API Viewer defines 1000's of constants prior to Vista. If you know which header file the constants come from you can google for that header (suffix of .h) and view the constants within. Otherwise, I typically hope google-fu works and search for something like: "const value", replace value with the actual constant name

    Edited: Note that the API Viewer is a really good tool, but not error free. For example, it may define a constant as &H8000 which should've been &H8000&. There may be a few constants that are simply wrong, but they are very few and far between. Long story short: get the constant value from the horse's mouth (documentation) if possible.
    Last edited by LaVolpe; Jan 10th, 2018 at 06:52 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    18,570

    Re: How to quickly view the constant values required by the standard-dll API function

    For many things the documentation lacks definitions and gives only symbolic names.

    I try to keep a recent Windows SDK installed.

    I make a shortcut to get me to the Include folder quickly, and I tell Windows to index that folder so I can use Explorer to quickly search for things like FOURCC_MEM when I need them. This brings up one or more files, which I open in Notepad and do a Find within.

    I still use the API Viewer for older, more common things but I consider it a distant secondary source for most stuff these days. The info there is around Windows 95 vintage.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2012
    Posts
    814

    Re: How to quickly view the constant values required by the standard-dll API function

    Thank @LaVolpe and @dilettant for your reply. I'll try The API Viewer.

    Edit:
    I looked at The API Viewer and it doesn't have the constants needed for the winmm.dll in its database.
    Last edited by dreammanor; Jan 11th, 2018 at 07:03 AM.

  5. #5
    Addicted Member
    Join Date
    Jun 2015
    Posts
    170

    Re: How to quickly view the constant values required by the standard-dll API function

    another nice thing to do is to make an enumeration out of the constants once you find them and set the api arg as that enumeration type then when using it intellisense will pop up and let you choose. it will default to a long value type

  6. #6
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,859

    Re: How to quickly view the constant values required by the standard-dll API function

    I really only see a couple options. Learn enough C/C++ to read the SDK files as dilettante and most of us do.
    Or come on here and ask
    Imagine what it would be like to set breakpoints in, or step through subclassing code;
    and then being able to hit stop/end/debug or continue, without crashing the IDE.

    VB6.tlb | Bulletproof Subclassing in the IDE (no thunks/assembly/DEP issues)

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    18,570

    Re: How to quickly view the constant values required by the standard-dll API function

    A huge downside to any "API" snippet tool is that the function signatures you need can't be predicted ahead of time.

    Sometimes you might want a Long returned and other times you might assign an Enum as the return type. Sometimes you want to pass a pointer explicitly and sometimes you want to pass a specific type ByRef. Sometimes As Any works fine and other times it can lead to problems that can take hours to find.

    If you don't know enough C, C++, and VB to deal with this then you'd be better off looking for wrapper classes written by somebody else.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2012
    Posts
    814

    Re: How to quickly view the constant values required by the standard-dll API function

    Quote Originally Posted by dz32 View Post
    another nice thing to do is to make an enumeration out of the constants once you find them and set the api arg as that enumeration type then when using it intellisense will pop up and let you choose. it will default to a long value type
    Thank you for your reply.

    Quote Originally Posted by DEXWERX View Post
    I really only see a couple options. Learn enough C/C++ to read the SDK files as dilettante and most of us do.
    Or come on here and ask
    Yes, reading the SDK files is a way.

    Quote Originally Posted by dilettante View Post
    A huge downside to any "API" snippet tool is that the function signatures you need can't be predicted ahead of time.

    Sometimes you might want a Long returned and other times you might assign an Enum as the return type. Sometimes you want to pass a pointer explicitly and sometimes you want to pass a specific type ByRef. Sometimes As Any works fine and other times it can lead to problems that can take hours to find.

    If you don't know enough C, C++, and VB to deal with this then you'd be better off looking for wrapper classes written by somebody else.
    Agree with you, but in most cases, those wrapper classes written by somebody else don't meet our own requirements.

  9. #9
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,859

    Re: How to quickly view the constant values required by the standard-dll API function

    Quote Originally Posted by dreammanor View Post
    Agree with you, but in most cases, those wrapper classes written by somebody else don't meet our own requirements.
    The same can be (was) said of API Declares. I actually use API Viewer, but you'll notice most of the declares are really sloppy, because they weren't converted by hand - merely by search and replace. More often than not you can count on the the Unicode/W declares being wrong. But it does save a little typing
    Imagine what it would be like to set breakpoints in, or step through subclassing code;
    and then being able to hit stop/end/debug or continue, without crashing the IDE.

    VB6.tlb | Bulletproof Subclassing in the IDE (no thunks/assembly/DEP issues)

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width