Hide Table of Contents

This topic describes how to create a C++ Windows MFC stand-alone application that logs into a SOLIDWORKS PDM Professional file vault and lists the files in the root folder.

  1. Start up Microsoft Visual Studio.
  2. Click File > New > Project > Visual C++ > MFC/ATL > MFC Application.
    1. Type the name of your project in Name.
    2. Click the Browse button and browse to the folder where to create your project.
    3. Click OK.
    4. Click Next.
    5. Select application type, Dialog based.
    6. Click Next, Next, and Next.
    7. Click Finish.
    8. Click Build > Build Solution.
  3. Copy C:\Program Files\SOLIDWORKS PDM\EdmInterface.dll to the project folder.
  4. Drag a button from the Toolbox onto the form.
  5. Double-click Button1 on the form.
  6. Add the following code after the #include statements:
    #import "Edminterface.dll" no_namespace
  7. Find and replace //TODO: Add your control notification handler code here, which appears in the button's command handler, with the following code. Fix the formatting of the code if needed.
    //Initialize COM (Usually done just once, for instance in InitInstance.)

    IEdmVault5Ptr poVault;
    HRESULT hRes = poVault.CreateInstance( __uuidof(EdmVault5), NULL );
    //Create a vault interface.
    if( FAILED(hRes) )

    //Log in on the vault.
    poVault->LoginAuto( "MyVault", (long)m_hWnd );

    //Get a pointer to the root folder.
    IEdmFolder5Ptr poFolder;
    poFolder = poVault->RootFolder;

    //Get position of first file in the folder.
    IEdmPos5Ptr poPos;
    poPos = poFolder->GetFirstFilePosition();

    CString oMessage;
    if( poPos->IsNull )
    oMessage = "The root folder of your vault does not contain any files.";
    oMessage = "The root folder of your vault contains these files:\n";

    while( poPos->IsNull == VARIANT_FALSE )
    IEdmFile5Ptr poFile = poFolder->GetNextFile( poPos );
    oMessage += (LPCTSTR)poFile->GetName();
    oMessage += "\n";

    AfxMessageBox( oMessage );
    catch( const _com_error &roError )
    //We get here if one of the methods above failed.
    if( poVault == NULL )
    AfxMessageBox( _T("Could not create vault interface." ));
    BSTR bsName = NULL;
    BSTR bsDesc = NULL;
    poVault->GetErrorString( (long)roError.Error(), &bsName, &bsDesc );
    bstr_t oName( bsName, false );
    bstr_t oDesc( bsDesc, false );

    bstr_t oMsg = "Something went wrong.\n";
    oMsg += oName;
    oMsg += "\n";
    oMsg += oDesc;
    AfxMessageBox( oMsg );

    //Deinitialize COM.
  1. Replace MyVault in the code with the name of a SOLIDWORKS PDM Professional vault on your computer.
  2. If creating this project on a 64-bit computer, change the platform to x64:
    1. Right-click the name of your project in the Solution Explorer and click Properties.
    2. Click the Configuration Manager button.
    3. Click the down-arrow button in the Platform column and select New. 
    4. Select x64 in New platform and click OK.  
    5. Click Close. If Active(x64) is not shown in Platform, then repeat Steps 2 - 5 until it is. 
    6. Click OK.
  3. Specify the project configuration properties:
    1. Right-click the name of your project in the Solution Explorer and click Properties.
    2. Click Configuration Properties > General.
    3. Set Use of MFC to Use MFC in a Shared DLL.
    4. Set Character Set to Use Unicode Character Set.
  4. Click Build > Clean Solution.
  5. Click Build > Rebuild Solution.
  6. Click Debug > Start Debugging or press F5.
    1. Click Button1.
      A message box is displayed that either contains the names of the files in the root folder of the specified vault or informs you that the root folder of the specified vault does not contain any files.
    2. Close the form.
  7. Click File > Save All.

 See Also

Stand-alone Applications (VB.NET)

Destroy Deleted Files in Vault Example (C++)

Destroy Deleted Files in Vault Example (VB.NET)

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Stand-alone Applications (C++)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2024 SP02

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.