Extracting Enum values from an assembly file using the Object Browser in FoxPro

Thanks to a helpful comment from Doug Hennig, I’ve learned how to use the Object Browser in Foxpro to extract Enum values from an assembly file right into a .h file inside of FoxPro.  By an “assembly”, I mean a dll file that is installed on your machine when you install software or API tools to communicate with various software packages.

For instance, here is the Object Browser in FoxPro taking a peek inside a dll assembly from the QuickBooks SDK ver 10:


I posted an article recently about communicating with QuickBooks from FoxPro, where I explained some problems I began having with the .h include file I was using, which had become out of date when we upgraded to the latest version of the QuickBooks SDK. You can see that post here if you’re interested in the original problem I was having: http://mattslay.com/adding-custom-data-to-quickbooks-invoices-from-foxpro/

The problem was that I needed the latest Enum values (“constants” in FoxPro) from the new assembly that came with the QB SDK ver 10. The Enums from a dll are exposed nicely when programming inside Visual Studio, but there is no FoxPro .h include file included in the QuickBooks SDK for us Fox programmers. I knew the information I needed to create a FoxPro .h file was hidden away in that .dll somewhere, I just didn’t know how to get them out of there in an automated fashion. In the original post linked above, I showed where I was able to see them inside of Visual Studio, and even determine the values of each one, but it was a very manual process. I was sure there was a better way. And there was. It was super-smart FoxPro MVP Doug Hennig who showed me the way, using the Object Browser in FoxPro.

So, with a little expansion on Doug’s original hint, I was eventually able to drag-and-drop the  entire Enum node from that QB assembly file right into a code file in FoxPro to get a full list of constants nicely defined and formatted in a .h include file.

It turns out that the Object Browser in FoxPro has some pretty good (but not perfect) support for this… It was close, but not exactly what I needed, since it required a LOT of manual drag-and-drop maneuvers. So I Googled around and stumbled upon the golden nugget that I needed to completely solved the problem to my liking. To dig into the solution I found, you can check it out here: http://www.dbmonster.com/Uwe/Forum.aspx/foxpro/7047/Utility-to-extract-print-all-enumerations. I am not going to repeat all the code and discussion from that thread in this post, just to avoid redundancy. There’s a lot to be learned from reading the thread yourself if you want to dig into the details, but that’s not necessary unless you want to explore the issue deeper. In short, I followed the thread and picked out the various instructions and was able to have it all working in just a few minutes.  So, to make it easy for everyone else, you can skip all the details in that post and just download the enhanced version of the Object Browser from the links below. Or, If you want to dig deeper into the code yourself, I’ve given you the steps you’ll need to follow to make the modifications yourself….

Instructions to modify the Object Browser for Enum Extraction

Fortunately, the source code for many of the FoxPro tools like the Object Browser were release to the community a few year ago so we could enhance them and keep the tools current.  That’s what the guys in the dbmonster post did to solve this problem (link below), and I’ve wrapped it all up here in an easy download file to share it with you:

Option 1 – Download the modified file from my site and start using it now:

If you do not want to modify the code yourself, you can download the .exe file that I built from here: http://mattslay.com/download-files/object-browser-modified-for-enums.exe

If you want a copy of the modified source code, you can download the whole project here: http://mattslay.com/download-files/object-browser-modified-for-enums.zip

Option 2 – Do it yourself – To update the FoxPro Object Browser yourself with this expanded functionality, follow these steps…

1. Go to the VFPX site and download the Xsource code here: http://vfpx.codeplex.com/wikipage?title=XSource. Extract the ‘obrowser’ tool from the zip and open the project file in VFP.

2. Make these changes to the source code… (follow the discussion and see the code at this link: http://www.dbmonster.com/Uwe/Forum.aspx/foxpro/7047/Utility-to-extract-print-all-enumerations

3. Next, compile the project to an .exe (name and location is your choice).

4. Now you can run your new version of the Object Browser to accomplish this task and output shown above.


Here’s the beautiful output you’ve been waiting to see.  (Note: I manually added the top few lines of comments to record some notes about how the files was created and what version is.)

By the way, if you happen to need the complete QBFC10Lib.h file that I’ve extracted for with FoxPro, you can download  it here: http://mattslay.com/download-files/QBFC10Lib.h   If you’re working with a different version of the QB SDK, then you should extract the Enums yourself from the correct dll from your version of the SDK, and build your own .h file.

*** FoxPro constants from QuickBooks SDK assembly QBFC10Lib
*** To see the origin of this file, visit this link:
***   http://mattslay.com/adding-custom-data-to-quickbooks-invoices-from-foxpro/

*— Constant Group: ENOpenMode
#DEFINE omSingleUser    0   
#DEFINE omMultiUser    1   
#DEFINE omDontCare    2   

*— Constant Group: ENRqOnError
#DEFINE roeStop    0   
#DEFINE roeContinue    1   
#DEFINE roeRollback    2   

*— Constant Group: ENReleaseLevel
#DEFINE rlPreAlpha    0   
#DEFINE rlAlpha    1   
#DEFINE rlBeta    2   
#DEFINE rlRelease    3   

*— Constant Group: ENRqResponseData
#DEFINE rdIncludeAll    0   
#DEFINE rdIncludeNone    1   



One thought on “Extracting Enum values from an assembly file using the Object Browser in FoxPro”

  1. BTW -After installing the Quickbooks SDK, you can find the QBFCxx.DLL file in this path:

    C:\Program Files(x86)\Common Files\intuit\QuickBooks

    Also note: When I installed the latest QBXML SDK 13.0 (on 2016-11-14), it actually installed QBFC10.dll, QBFC12.dll, and QBFC13.dll in that folder.

    Since my .h file was extracted for Ver 10, I’m hoping my code will still run without recompiling (which would mean extracting the .h file from Ver 13 and changing my code references from “”QBFC10.QBSessionManager” to “QBFC13.QBSessionManager”)

Leave a Reply

Your email address will not be published. Required fields are marked *