• 大小: 610KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-11
  • 语言: 其他
  • 标签:

资源简介

LabWindows_CVI调用外部程序的六种方法源代码

资源截图

代码片段和文件信息

#include 
#include “CVIShell.h“
#include 
#include 
#include 
//#include 
//#include 
//#include 
#include “d:\CVI例程\CVIShell的六种调用例程\CVIShell.h“

/*
typedef struct _SHELLEXECUTEINFOA
{
        DWORD cbSize;
        ULONG fMask;
        HWND hwnd;
        LPCSTR   lpVerb;
        LPCSTR   lpFile;
        LPCSTR   lpParameters;
        LPCSTR   lpDirectory;
        int nShow;
        HINSTANCE hInstApp;
        // Optional fields
        LPVOID lpIDList;
        LPCSTR   lpClass;
        HKEY hkeyClass;
        DWORD dwHotKey;
        union {
        HANDLE hIcon;
        HANDLE hMonitor;
        } DUMMYUNIONNAME;
        HANDLE hProcess;
} SHELLEXECUTEINFOA *LPSHELLEXECUTEINFOA;

ShellExecuteExA(
LPSHELLEXECUTEINFOA lpExecInfo
);
SHSTDAPI_(HINSTANCE) ShellExecuteA(
HWND hwnd 
LPCSTR lpOperation 
LPCSTR lpFile 
LPCSTR lpParameters 
LPCSTR lpDirectory 
INT nShowCmd
);

CreatePipe(
    OUT PHANDLE hReadPipe
    OUT PHANDLE hWritePipe
    IN LPSECURITY_ATTRIBUTES lpPipeAttributes
    IN DWORD nSize
    );

CreateProcessA(
    IN LPCSTR lpApplicationName
    IN LPSTR lpCommandLine
    IN LPSECURITY_ATTRIBUTES lpProcessAttributes
    IN LPSECURITY_ATTRIBUTES lpThreadAttributes
    IN BOOL bInheritHandles
    IN DWORD dwCreationFlags
    IN LPVOID lpEnvironment
    IN LPCSTR lpCurrentDirectory
    IN LPSTARTUPINFOA lpStartupInfo
    OUT LPPROCESS_INFORMATION lpProcessInformation
);

WinExec(
    IN LPCSTR lpCmdLine
    IN UINT uCmdShow
);

FindWindowA(
    IN LPCSTR lpClassName
    IN LPCSTR lpWindowName
);

SetParent(
    IN HWND hWndChild
    IN HWND hWndNewParent
);
*/

static int handle;
static int panelHandle;
void WinExecAndWait32(char * FileName int ShowMode);

void WinExecAndWait32(char * FileName int ShowMode)
{
SECURITY_ATTRIBUTES sa;
HANDLE hReadPipe;
HANDLE hWritePipe;
STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInfo;
    DisableBreakOnLibraryErrors (); //关闭异常显示
memset(&sa 0 sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
    sa.bInheritHandle = TRUE;
    sa.lpSecurityDescriptor = NULL;
if (CreatePipe(&hReadPipe &hWritePipe &sa 0)) {
memset(&StartupInfo 0 sizeof(STARTUPINFOA));
   StartupInfo.cb = sizeof(STARTUPINFOA);
StartupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
StartupInfo.wShowWindow = ShowMode;
StartupInfo.hStdOutput = hWritePipe;
StartupInfo.hStdError = hWritePipe;
CreateProcess(
(LPCSTR)NULL//lpApplicationName
(LPSTR)FileName//lpCommandLine
(LPSECURITY_ATTRIBUTES)&sa//lpProcessAttributes
(LPSECURITY_ATTRIBUTES)&sa//lpThreadAttributes
(BOOL)TRUE//bInheritHandles
(DWORD)NORMAL_PRIORITY_CLASS//dwCreationFlags
(LPVOID)NULL//lpEnvironment
(LPCSTR)NULL//lpCurrentDirectory
(LPSTARTUPINFOA)&StartupInfo//lpStartu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6549  2007-04-05 14:45  CVIShell的六种调用例程\cvibuild.CVIShell\build.ini

     文件     628349  2007-04-05 14:21  CVIShell的六种调用例程\cvibuild.CVIShell\CVIShell.nidobj

     文件        183  2007-04-05 14:21  CVIShell的六种调用例程\cvibuild.CVIShell\dependencies.bri

     文件       1996  2007-04-05 14:21  CVIShell的六种调用例程\cvibuild.CVIShell\resources.res

     目录          0  2007-04-05 12:09  CVIShell的六种调用例程\cvibuild.CVIShell

     文件       7544  2007-04-05 14:20  CVIShell的六种调用例程\CVIShell.c

     文件    1238260  2007-04-04 23:29  CVIShell的六种调用例程\CVIShell.cdb

     文件       4411  2007-04-05 14:21  CVIShell的六种调用例程\CVIShell.cws

     文件       1823  2007-04-05 10:48  CVIShell的六种调用例程\CVIShell.h

     文件       3480  2007-04-05 00:21  CVIShell的六种调用例程\CVIShell.prj

     文件       3320  2007-04-05 10:48  CVIShell的六种调用例程\CVIShell.uir

     文件    1246496  2007-04-05 14:21  CVIShell的六种调用例程\CVIShell_dbg.cdb

     文件     236544  2007-04-05 14:21  CVIShell的六种调用例程\CVIShell_dbg.exe

     目录          0  2007-04-05 12:09  CVIShell的六种调用例程

----------- ---------  ---------- -----  ----

              3378955                    14


评论

共有 条评论

相关资源