调用ShellExecute,说我未申明头文件。。。。

发布时间:2025-12-09 14:24:37 浏览次数:4

#include <windows.h>

#include <iostream>

#include <string.h>

#include <stdlib.h>

#include <tlhelp32.h> // 声明快照函数的头郑缺文件

using namespace std

//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )

int main(int argc, char* argv[])

{

char join[]="\""

char begin[128]

::GetCurrentDirectory(100,begin)

char end[]="\\Maxthon.exe"告睁

strcat(begin,end)

strcat(begin,join)

strcat(join,begin)

::ShellExecute(NULL,"open",join, NULL,NULL,SW_SHOW )

printf("%s\n",join)

return 0

}

右键点工程名,选设置喊友辩,然后选c/c++属性页,再选catagory选单中选 precompiled header ,将选项置成no use 或者autometic

WebBrowser的网页属性氏灶对框很简单。

webBrowser1.ShowPropertiesDialog()

就可以了。

文件的windows属性对话框比较麻烦,建议直接自己写窗体,读出各项属性。

如果要调用windows的,方法如下:

1、引用命名空洞仿间

using System.Runtime.InteropServices

2、定义一个Struct,用于传递参数

[StructLayout(LayoutKind.Sequential)]

public struct SHELLEXECUTEINFO

{

public int cbSize

public uint fMask

public IntPtr hwnd

[MarshalAs(UnmanagedType.LPStr)]

public string lpVerb

[MarshalAs(UnmanagedType.LPStr)]

public string lpFile

[MarshalAs(UnmanagedType.LPStr)]

public string lpParameters

[MarshalAs(UnmanagedType.LPStr)]

public string lpDirectory

public int nShow

public IntPtr hInstApp

public IntPtr lpIDList

[MarshalAs(UnmanagedType.LPStr)]

public string lpClass

public IntPtr hkeyClass

public uint dwHotKey

public IntPtr hIcon

public IntPtr hProcess

}

3、导入Windows API函数和一些常量

private const int SW_SHOW = 5

private const uint SEE_MASK_INVOKEIDLIST = 12

[DllImport("shell32.dll")]

static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo)

4、写调用查看文件属性的对话框

public static void ShowFileProperties(string Filename)

{

SHELLEXECUTEINFO info = new SHELLEXECUTEINFO()

info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info)

info.lpVerb = "properties"

info.lpFile = Filename

info.nShow = SW_SHOW

info.fMask = SEE_MASK_INVOKEIDLIST

ShellExecuteEx(ref info)

}

这样就能通过ShowFileProperties("xxxx")来调用查看文件对话框纳核纤了。


需要做网站?需要网络推广?欢迎咨询客户经理 13272073477