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 2010.
  2. Click File > New > Project > Visual C++ > MFC > 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 Edm.tlb from the API subfolder of the SOLIDWORKS PDM Professional CD to project_path\project_name\project_name.
  4. Register Edm.tlb. For example, on a computer running Windows 7 x64:
    1. Search the disk where Windows 7 x64 was installed for regtlibv12.exe.
    2. Open a command window and type:
      >cd path_to_regtlibv12.exe
      >regtlibv12.exe "project_path\project_name\project_name\Edm.tlb"
    3. Close the command window.
  5. Drag a button from the Toolbox onto the form.
  6. Double-click Button1 on the form.
  7. Type the following code at the top of the code after the #include statements:
    #import "Edm.tlb" no_namespace
  8. 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.)
    CoInitialize(0);

    IEdmVault5Ptr poVault;
    HRESULT hRes = poVault.CreateInstance( __uuidof(EdmVault5), NULL );
    try
    {
    //Create a vault interface.
    if( FAILED(hRes) )
    _com_issue_error(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.";
    else
    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." ));
    }
    else
    {
    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.
    CoUninitialize();
  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 Windows 7 x64 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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Stand-alone Applications (C++)
*Comment:  
*   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:



x

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
x

Web Help Content Version: API Help (English only) 2018 SP05

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.