NX二次开发—按钮UI实现简单功能
作者:互联网
#include "uf_all.h" #include <io.h> #include <iostream> #include <fstream> #include <string.h> #include <stdio.h> #include <afxwin.h> #include <winuser.h> #include <windows.h> #include <shlwapi.h> #include <shlobj.h> #include <shellapi.h> #include <winuser.h> #include <tlhelp32.h> using namespace std; extern DllExport void ufsta(char* param, int* returnCode, int rlen) { //单选菜单列表对话框 【按钮】 char items[4][38] = { "men文件", "rib文件", "YHD标准", "插件加载" }; int response = uc1603("菜单", 0, items, 4); if (response == 5) { //用记事本打开文件 char txt[256 + 1] = "D:\\DS_tool\\startup\\DS.men"; char eexe[512] = " "; sprintf(eexe, "notepad.exe %s", txt); LPWSTR txtt = CA2W(eexe); STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi = { 0 }; if (CreateProcess(NULL, txtt, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } } if (response == 6) { //用记事本打开文件 char txt[256 + 1] = "D:\\DS_tool\\startup\\DS_Tool.rtb"; char eexe[512] = " "; sprintf(eexe, "notepad.exe %s", txt); LPWSTR txtt = CA2W(eexe); STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi = { 0 }; if (CreateProcess(NULL, txtt, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } } if (response == 7) { //用记事本打开文件 char txt[256 + 1] = "D:\\DS_tool\\application\\HYD.utd"; char eexe[512] = " "; sprintf(eexe, "notepad.exe %s", txt); LPWSTR txtt = CA2W(eexe); STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi = { 0 }; if (CreateProcess(NULL, txtt, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } } if (response == 8) { char* pathvar = ""; pathvar = getenv("UGII_ROOT_DIR"); if ((NULL != pathvar) && (0 != strlen(pathvar))) { //uc1601(pathvar, 1); /*设置UG内部变量(修改是临时的重启UG会还原变量值)*/ //int iRet = putenv("UGII_LANG=ENGLISH"); char txt[256 + 1] = "menus\\custom_dirs.dat"; const char* result = NULL; char eexe[512] = " "; string temp = string(pathvar) + string(txt); result = temp.c_str();//result即为合并后的结果 //用记事本打开文件 sprintf(eexe, "notepad.exe %s", result); LPWSTR txtt = CA2W(eexe); STARTUPINFO si = { sizeof(si) }; PROCESS_INFORMATION pi = { 0 }; if (CreateProcess(NULL, txtt, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } } } //response 后退=1;取消=2; 第1项=5;第2项=6;第3项=7 } extern int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }
标签:char,pi,NX,include,si,eexe,UI,二次开发,NULL 来源: https://www.cnblogs.com/XDS2022/p/16440538.html