Solved

Borland C++ .... SetupGetStringField (returning a value from a INF File)

Posted on 2003-11-17
2
941 Views
Last Modified: 2012-06-27
Hello,

I've used an INF file on our current application to store some parameters.
However, we appear to be experiencing problems with the SetupGetStringField function.
i.e. it doesn't appear to be returning anything.


I've used SetupOpenInfFile to open the INF file and SetupFindFirstLine to find the first line which contains the relevant section and key.
However SetupGetStringField  doesn't appear to be working.


Can you have a look at the code to see what the problem is and/or suggest a different approach which be easier?

hope you can help.


Cheers, weslondon


~~~~~~~~~~~~~

        DWORD dwResult;
        HINF hInf;                     //variable to hold the INF handle
        UINT ErrorLine;                //variable to hold errors returned

        INFCONTEXT aContext = {0};
        char *  aReturnBuffer;
        DWORD aReturnBufferSize;
        PDWORD aRequiredSize;

        BOOL aLineFound = 0;
        BOOL aStrEntryFound = 0;

        strcpy (aInfName, "C:/Inf.inf");

        hInf = SetupOpenInfFile (
               aInfName,
               NULL,
               INF_STYLE_WIN4,
               &ErrorLine);           //line number of the syntax error

        if (hInf == INVALID_HANDLE_VALUE)
        {
            return NULL;
        }
        else
        {
            // Find correct line - using aSection and aKey

            aLineFound = SetupFindFirstLine(
                hInf,              // handle to an INF file
                aSection,      // section in which to find a line
                aKey,              // optional, key to search for
                &aContext      // context of the found line
            );

            if (aLineFound)
            {
                // Extract value using &aContext

                aStrEntryFound = SetupGetStringField(
                &aContext,                    // context of the INF file
                1,                            // index of the field to get
                aReturnBuffer,            // optional, receives the field
                aReturnBufferSize,            // size of the provided buffer
                NULL                      // optional, buffer size needed
                );
            }
            if (aStrEntryFound)
            {
                SetupCloseInfFile(hInf);
                return aReturnBuffer;
            }

~~~~~~~~~~~

N.B aStrEntryFound is false
(i.e. nothing returned in aReturnBuffer)



0
Comment
Question by:weslondon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9765840
You are not specifying a valid return buffer - use

       char *  aReturnBuffer [ 1024]; // or whatever size is appropriate
       DWORD aReturnBufferSize = sizeof ( aReturnBuffer);

The docs state: "ReturnBuffer
This optional parameter points to a caller-supplied buffer "
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 9765849
Ooops, sorry, that should read

      char  aReturnBuffer [ 1024]; // or whatever size is appropriate
      DWORD aReturnBufferSize = sizeof ( aReturnBuffer);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question