Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to write a function than can get all install files according a inf file.
how to use TInfContext?

Delphi
var
  h: HINF;
  sClass: string;
  Context: TInfContext;
  ReturnBuffer: PChar;
  RequiredSize: DWORD;
  SourceId: UINT;
begin
  sClass := GetInfClass(AInfFile);
  h := SetupOpenInfFile(PChar(AInfFile), PChar(sClass), INF_STYLE_WIN4, nil);
  if DWORD(h) <> INVALID_HANDLE_VALUE then
  try
    SetLastError(0);
    //I don't know how to use Context parameter,GetLastError return 3758096642
    Context.Inf := h;
    Context.CurrentInf := h;
    Context.Section := 10;
    Context.Line := 10;
    SetupGetSourceFileLocation(h, @Context, nil, SourceId, nil, 0, @RequiredSize);
    if GetLastError() = ERROR_INSUFFICIENT_BUFFER then
    begin
      ReturnBuffer := GetMemory(RequiredSize);
      try
        SetupGetSourceFileLocation(h, @Context, nil, SourceId, ReturnBuffer,
          RequiredSize, nil);
      finally
        FreeMemory(ReturnBuffer);
      end;
    end
    else
      OutputDebugString(PChar(IntToStr(GetLastError())));
  finally
    SetupCloseInfFile(h);
  end;
Posted
Updated 17-Nov-11 15:57pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900