Listing files

Top  Previous  Next

In the following code sample, the function VirtFsEnumCallback is a callback functions that receives all files in a virtual package called C:\MyPackage.exe:

 

// Callback function

BOOL _stdcall

VirtFsEnumCallback(

   LPVOID                           Data,

   IN  WCHAR*                       FileName,

   IN  ULONG                        FileFlags,

   LARGE_INTEGER                    CreationTime,

   LARGE_INTEGER                    LastAccessTime,

   LARGE_INTEGER                    LastWriteTime,

   LARGE_INTEGER                    ChangeTime,

   LARGE_INTEGER                    EndOfFile,

   ULONG                            FileAttributes )

{

   printf("%x: %ws\n", Data, FileName);

   return (TRUE);

}

 

// Enumeration sample function

void EnumSample ()

{

   PACKAGE_HANDLE        hPkg;

   if (PackageOpen(L"C:\\MyPackage.exe", 0, &hPkg) == APIRET_SUCCESS)

   {

      // Modify package property "AutoLaunch"

      VirtFsEnum(hPkg, VirtFsEnumCallback, (LPVOID)0x12345678);

 

      // Save and close package

      PackageSave(hPkg, L"c:\\now\\output.exe");

      PackageClose(hPkg);

   }

}