Call propauto.dll in C++

 

HI Jason,

 

do you have an example of how to call propauto.dll from SOlidEdge?

thank you.

Regards

Massimo

 

Posted by: Massimo Magris
Post date: 1/25/2009 10:01:50 PM

2 REPLIES

RE: Call propauto.dll in C++

 

Here is an example for you.  This example was created in VC++ 2008 so your stdafx.h may vary a bit.  I also added this code to http://wiki.jasonnewell.net/SDK.ashx.

 

 // stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//#pragma once// The following macros define the minimum required platform. The minimum required platform// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run // your application. The macros work by enabling all features available on platform versions up to and // including the version specified.// Modify the following defines if you have to target a platform prior to the ones specified below.// Refer to MSDN for the latest info on corresponding values for different platforms.#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.#endif#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.#endif#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.#endif#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.#endif#include #include #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit#include #include #define IfFailGo(x) { hr=(x); if (FAILED(hr)) goto Error; }#define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(!p) {hr = E_FAIL; goto Error; } }#import "libid:AED8FE52-3129-11D1-BC83-0800360E1E02"using namespace SolidEdgeFileProperties;

 

 // PropAutoExample.cpp : Defines the entry point for the console application.//#include "stdafx.h"void ModifyCustomProperty(SolidEdgeFileProperties::IJPropertiesPtr pProperties, _bstr_t Name, const _variant_t & Value);int _tmain(int argc, _TCHAR* argv[]){ if (argc Open(argv[1], VARIANT_FALSE)); /* Example of how to loop through PropertySets */ for (LONG i = 0; i Count; i++) { pProperties = pPropertySets->GetItem(_variant_t(i)); CString strPropertySetName = pProperties->Name; /* Example of how to loop through Properties */ for (LONG j = 0; j Count; j++) { pProperty = pProperties->GetItem(_variant_t(j)); CString strPropertyName = pProperty->Name; } } /* Get custom properties */ pProperties = pPropertySets->GetItem(_variant_t(_T("Custom"))); /* ModifyCustomProperty will either modify or add the custom property */ ModifyCustomProperty(pProperties, _T("My Custom String Property"), _variant_t(_T("Hello"))); ModifyCustomProperty(pProperties, _T("My Custom Number Property"), _variant_t((LONG)123)); ModifyCustomProperty(pProperties, _T("My Custom Boolean Property"), _variant_t(VARIANT_TRUE, VT_BOOL)); /* Save Custom PropertySet */ IfFailGo(pProperties->Save()); /* Save document */ IfFailGo(pPropertySets->Save());Error: /* Close document */ if (pPropertySets != NULL) hr = pPropertySets->Close(); /* Release smart-pointers */ pProperty = NULL; pProperties = NULL; pPropertySets = NULL; CoUninitialize(); return 0;}void ModifyCustomProperty(SolidEdgeFileProperties::IJPropertiesPtr pProperties, _bstr_t Name, const _variant_t & Value){ SolidEdgeFileProperties::IJPropertyPtr pProperty = NULL; /* GetItem will throw an exception if item does not exist */ _ATLTRY { pProperty = pProperties->GetItem(Name); pProperty->Value = Value; } _ATLCATCHALL() { pProperty = pProperties->Add(Name, Value); } pProperty = NULL;}

 

Posted by: Jason Newell
Post date: 1/27/2009 5:33:44 AM

RE: Call propauto.dll in C++

 

Thank you Jason!!

That's exactly what I need.

ciao

Massimo

 

Posted by: Massimo Magris
Post date: 1/27/2009 5:51:06 AM