Proe5.0导出PDF至配置文件的相关方法,VC++
生活随笔
收集整理的這篇文章主要介紹了
Proe5.0导出PDF至配置文件的相关方法,VC++
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
定義文件bcsMessage.txt
PLM
PLM
PLM
#
login
login
測試
#
Active messagebox menu
Active messagebox menu
激活菜單
#
將Menu文件放置與程序同級的text文件夾下
配置ini文件
[BCS]
Path=C:\3
將配置文件放置Proe的工作目錄下
?
代碼如下:
C++
// bcsproe.cpp : 定義 DLL 的初始化例程。 //#include "stdafx.h" #include "bcsproe.h" #include "afx.h"#include "ProMenu.h" #include "ProUtil.h" #include "ProMenubar.h" #include "ProPDF.h"static uiCmdAccessState AccessDefault (uiCmdAccessMode); void login(); void exportpdf();#ifdef _DEBUG #define new DEBUG_NEW #endif// CbcsproeAppBEGIN_MESSAGE_MAP(CbcsproeApp, CWinApp) END_MESSAGE_MAP()// CbcsproeApp 構造CbcsproeApp::CbcsproeApp() {// TODO: 在此處添加構造代碼,// 將所有重要的初始化放置在 InitInstance 中 }// 唯一的一個 CbcsproeApp 對象CbcsproeApp theApp;// CbcsproeApp 初始化BOOL CbcsproeApp::InitInstance() {CWinApp::InitInstance();return TRUE; } extern "C" int user_initialize() {ProError status;ProFileName message_file;uiCmdCmdId cmd_id1;ProFileName MsgFile;ProStringToWstring(MsgFile, "bcsMessage.txt");status=ProMenubarMenuAdd ("PLM", "PLM","Utilities", PRO_B_TRUE, MsgFile);//loginstatus = ProCmdActionAdd("ShowTest1",(uiCmdCmdActFn)login,uiCmdPrioDefault,AccessDefault,PRO_B_TRUE,PRO_B_TRUE,&cmd_id1);status = ProMenubarmenuPushbuttonAdd("PLM", "login", "login","Active messagebox menu", NULL,PRO_B_TRUE, cmd_id1, ProStringToWstring(message_file, "bcsMessage.txt"));return status; }extern "C" void user_terminate() {AFX_MANAGE_STATE(AfxGetStaticModuleState()); }/*================================================================*\ FUNCTION: AccessDefault() \*================================================================*/ static uiCmdAccessState AccessDefault (uiCmdAccessMode access_mode) {return (ACCESS_AVAILABLE); }void login()/消息框 {exportpdf();return; }void exportpdf() {ProError err;ProPath current_path;char c_p[200];err=ProDirectoryCurrentGet(current_path);if (err!=PRO_TK_NO_ERROR){AfxMessageBox(_T("未獲取到Proe起始目錄"));return;}ProWstringToString(c_p,current_path);CString strcurrent_path = current_path;獲取配置文件路徑CString FileName =L"\\bcsConfiguration.ini"; LPTSTR lpPath = new TCHAR[MAX_PATH];LPWSTR Path = new TCHAR[MAX_PATH];strcurrent_path = strcurrent_path + FileName;//AfxMessageBox(strcurrent_path);GetPrivateProfileString(L"BCS",L"Path",L"",Path,MAX_PATH,strcurrent_path);//AfxMessageBox(Path);if (_tcslen(Path) < 1){AfxMessageBox(L"未找到配置信息!");return;}delete [] lpPath;ProPDFOptions ops;ProPDFoptionsAlloc(&ops);ProMdl mdl;//獲取文件名err = ProMdlCurrentGet(&mdl);if (PRO_TK_NO_ERROR != err){AfxMessageBox(_T("當前沒有文件打開"));return;}ProMode mode;err = ProModeCurrentGet(&mode);if (err != PRO_TK_NO_ERROR){AfxMessageBox(_T("未獲取到當前打開文件"));return;}if (mode != PRO_MODE_DRAWING){AfxMessageBox(_T("當前只支持DRW文件導出pdf"));return;}ProName name;err = ProMdlNameGet(mdl, name);CString cstrName = name;CString outfilepathname = Path;outfilepathname = outfilepathname +L"\\" + cstrName + L".pdf";//AfxMessageBox(outfilepathname.GetBuffer(0));//導出pdfProPDFExport(mdl,outfilepathname.GetBuffer(0),ops);ProPDFoptionsFree(ops);AfxMessageBox(_T("導出完成!"));彈出一個消息框 }?
下面是關于在Proe客戶端的配置
定義注冊文件
?Protk.dat
內容如下:
NAME pt_inst_test STARTUP DLL ALLOW_STOP TRUE DELAY_START FALSE EXEC_FILE C:/Documents and Settings/Administrator/My Documents/bcsproe.dll TEXT_DIR C:/Documents and Settings/Administrator/My Documents/text REVISION 1000 END
若想實現Proe自動注冊,則將此文件放置Proe的安裝目錄的text文件下,例如:C:\Program Files\proeWildfire 5.0\text,具體路徑根據自己安裝目錄指定
注:文件名必須為Protk不能更換
?
轉載于:https://www.cnblogs.com/fanxingthink/p/4176152.html
總結
以上是生活随笔為你收集整理的Proe5.0导出PDF至配置文件的相关方法,VC++的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是财富
- 下一篇: 贪吃蛇游戏(附源码)