Hide Table of Contents

Visual C++ 6.0 Standalone and Add-in Applications

Standalone Applications (.exe files)

To create an instance of the SOLIDWORKS software, your executable project should contain lines of code similar to the following:

 

//Import the SOLIDWORKS type library

#import "sldworks.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids

//Import the SOLIDWORKS constant type library    

#import "swconst.tlb"  raw_interfaces_only, raw_native_types, no_namespace, named_guids  

 

int _tmain(int argc, _TCHAR* argv[])  

{

//Initialize COM

CoInitialize(NULL);  

     

//Use ATL smart pointers

CComPtr<ISldWorks> swApp;

 

//Create an instance of SOLIDWORKS

HRESULT hres = swApp.CoCreateInstance(__uuidof(SldWorks), NULL, CLSCTX_LOCAL_SERVER);

.

. // Your code

.   

//Shut down SOLIDWORKS

swApp->ExitApp();

 

//Release COM reference

swApp = NULL;

 

//Uninitialize COM

CoUninitialize();

 

return 0;

}

Add-in Applications (.dll files)

Visual C++ applications have the option of using a COM or Dispatch interface. See COM vs. Dispatch for details.

NOTE: For COM DLL add-ins, success or failure on import/export is returned by the add-in through the HRESULT.



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:   Visual C++ 6 Standalone and Add-in Applications
*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) 2021 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.