18.08.2013 Views

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5Vi<br />

<strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong> Sample Code 5<br />

This chapter discusses the VDDK sample program, in the following sections:<br />

“Compiling the Sample Program” on page 43<br />

“Usage Message” on page 44<br />

“Walk‐Through of Sample Program” on page 45<br />

Compiling the Sample Program<br />

The sample program is written in C++, although the <strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong> also supports C.<br />

For compilation to succeed, the correct DLLs or shared objects must be loaded. You can ensure the success of<br />

dynamic loading in a variety of ways.<br />

Set the path inside the VDDK program.<br />

Set the path for the shell being used in Linux or in Visual Studio for Windows.<br />

For a default installation, the Linux path is /usr/share/doc/vmware-vix-disklib/sample.<br />

In Windows, set the Path element in the System Variables.<br />

To do this in Windows XP, right‐click Computer > Properties > Advanced > Environment Variables,<br />

select Path in the System Variables lower list, click Edit, and add the path of the VDDK bin directory.<br />

In Windows 7, right‐click Computer > Properties > Advanced System Settings > Environment Variables,<br />

select Path in the System Variables list, click Edit, and add the path of the VDDK bin directory.<br />

C:\Program Files\<strong>VMware</strong>\<strong>VMware</strong> <strong>Virtual</strong> <strong>Disk</strong> Development Kit\doc\sample\ is the default path.<br />

Note that VDDK loads DLLs by relative path rather than absolute path, so conflicting versions of the DLLs<br />

could cause problems.<br />

Visual C++ on Windows<br />

To compile the program, find the sample source vix<strong>Disk</strong>LibSample.cpp at this location:<br />

C:\Program Files\<strong>VMware</strong>\<strong>VMware</strong> <strong>Virtual</strong> <strong>Disk</strong> Development Kit\doc\sample\<br />

Double‐click the vcproj file, possibly convert format to a newer version, and choose Build > Build Solution.<br />

To execute the compiled program, choose Debug > Start Without Debugging, or type this in a command<br />

prompt after changing to the doc\sample location given above:<br />

Debug\vixdisklibsample.exe<br />

SLN and VCPROJ Files<br />

The Visual Studio solution file vix<strong>Disk</strong>LibSample.sln and project file vix<strong>Disk</strong>LibSample.vcproj are<br />

included in the sample directory.<br />

<strong>VMware</strong>, Inc. 43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!