PackageOpen

Top  Previous  Next

int _stdcall

PackageOpen(

   IN  LPWSTR                       PackageExeFile,

   IN  LPWSTR                       AppVirtDll,

   IN  LPWSTR                       LoaderExe,

   OUT PACKAGE_HANDLE*              phPkg )

Opens an existing virtual application package for read/write. Returns a handle that can then be used for manipulating virtual application packages.

Parameters

PackageExeFile [in]

Name of the existing package file (usually ending with .exe).

AppVirtDll [in]

Complete path to the virtualization engine to be used (AppVirtDll.dll).

LoaderExe [in]

Complete path to the loader to be used (Loader.exe).

phPkg [out]

Pointer to a handle. If the function is successful, this parameter receives a handle to the open package handle. This handle must be closed with PackageClose when finished using the package.

Return value

If successful, the return value is APIRET_SUCCESS.

Code sample

PACKAGE_HANDLE   hPkg;

 

// Create package from scratch. No error checking.

// FullMyPath and RegWriteString are private functions; replace them with your own.

if (PackageCreate(L"MyVirtualPackage", FullMyPath(L"AppVirtDll.dll"), 

 FullMyPath(L"Loader.exe"), &hPkg) == APIRET_SUCCESS)

{

 // Add files to package

 VirtFsAdd(hPkg, L"c:\\now\\win7.png", L"%windows%\\win7.png", FALSE);                        // Add file, already-variablized name

 VirtFsAdd(hPkg, L"c:\\now\\install.ini", L"%Program Files%\\MyDir\\install.ini", TRUE);        // Add file, request to variablize name

 VirtFsAddEmptyDir(hPkg, L"%Program Files%\\MyDir\\TempDir", FALSE);                                // Add empty folder

 

 // Add registry entries to package

 CString WorkKey;

 VirtRegGetWorkKey(hPkg, WorkKey.GetBuffer(MAX_PATH), MAX_PATH);

 WorkKey.ReleaseBuffer();

 RegWriteString(HKEY_CURRENT_USER, WorkKey + L"\\Machine\\Software\\MySoft", L"SomeValue", L"Hello world");

 

 // Manipulate isolation (default = isolated)

 

 

 

 

SetRegistryFlags(hPkg, L"Machine\\Software\\MySoft", FALSE, SANDBOXFLAGS_PASSTHROUGH);        // Full access

 SandboxSetFileFlags(hPkg, L"%Program Files%\\MyDir\\TempDir", FALSE, SANDBOXFLAGS_PASSTHROUGH);        // Full access

 

 // Save & close package

 PackageSave(hPkg, PackageName);

 PackageClose(hPkg);

}