comdlg32.dll
dll的应用,目前还不知道要怎么查看dll里的功能,暂且试着用了一个,
下面的Declare 分32位office软件和64位,如果是64位,要在Declare 后面加上PtrSafe ,定义的Type里的Long也最好写成LongPtr
- Option Explicit
- Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Private Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (ByVal lpszFile As String, ByVal lpszTitle As String, ByVal cbBuf As Integer) As Integer
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Type OPENFILENAME
- lStructSize As Long
- hwndOwner As Long
- hInstance As Long
- lpstrFilter As String
- lpstrCustomFilter As String
- nMaxCustFilter As Long
- nFilterIndex As Long
- lpstrFile As String
- nMaxFile As Long
- lpstrFileTitle As String
- nMaxFileTitle As Long
- lpstrInitialDir As String
- lpstrTitle As String
- flags As Long
- nFileOffset As Integer
- nFileExtension As Integer
- lpstrDefExt As String
- lCustData As Long
- lpfnHook As Long
- lpTemplateName As String
- End Type
- Const OFN_READONLY = &H1
- Const OFN_OVERWRITEPROMPT = &H2
- Const OFN_HIDEREADONLY = &H4
- Const OFN_NOCHANGEDIR = &H8
- Const OFN_SHOWHELP = &H10
- Const OFN_ENABLEHOOK = &H20
- Const OFN_ENABLETEMPLATE = &H40
- Const OFN_ENABLETEMPLATEHANDLE = &H80
- Const OFN_NOVALIDATE = &H100
- Const OFN_ALLOWMULTISELECT = &H200
- Const OFN_EXTENSIONDIFFERENT = &H400
- Const OFN_PATHMUSTEXIST = &H800
- Const OFN_FILEMUSTEXIST = &H1000
- Const OFN_CREATEPROMPT = &H2000
- Const OFN_SHAREAWARE = &H4000
- Const OFN_NOREADONLYRETURN = &H8000
- Const OFN_NOTESTFILECREATE = &H10000
- Const OFN_NONETWORKBUTTON = &H20000
- Const OFN_NOLONGNAMES = &H40000
- Const OFN_EXPLORER = &H80000
- Const OFN_NODEREFERENCELINKS = &H100000
- Const OFN_LONGNAMES = &H200000
- Const OFN_SHAREFALLTHROUGH =
- Const OFN_SHARENOWARN =
- Const OFN_SHAREWARN =
- Const MAX_PATH =
- Sub test1105()
- Debug.Print Get_FileName("D:\lcx\", "我的测试选择", "XLS", True)
- End Sub
- 'strFilter = 过滤条件
- 'strInitialDir = 文件起始目录
- 'strTitle = 标题
- 'strDefExt = 过滤条件
- 'blOpen = 选择 True 保存 False
- Function spFileDlg(strFilter As String, strInitialDir As String, strTitle As String, strDefExt As String, blOpen As Boolean, FN As String)
- Dim fFileName As OPENFILENAME
- Dim strBuff As String
- Dim accWnd As Long
- Dim lngRet As Long
- accWnd = FindWindow("OMAIN", vbNullString)
- strBuff = FN & String$(MAX_PATH - LenB(FN), )
- With fFileName
- .lStructSize = LenB(fFileName)
- .hwndOwner = accWnd
- .hInstance =
- .lpstrFilter = strFilter
- .nMaxCustFilter = &
- .nFilterIndex =
- .lpstrFile = strBuff
- .nMaxFile = MAX_PATH
- .lpstrFileTitle = String$(MAX_PATH, )
- .nMaxFileTitle = MAX_PATH +
- .lpstrInitialDir = strInitialDir
- .lpstrTitle = strTitle
- .flags = OFN_HIDEREADONLY
- .lpstrDefExt = strDefExt
- End With
- If blOpen = True Then
- lngRet = GetOpenFileName(fFileName)
- Else
- lngRet = GetSaveFileName(fFileName)
- End If
- If lngRet <> Then
- spFileDlg = fFileName.lpstrFile
- Else
- spFileDlg = "CANCEL"
- End If
- End Function
- 'FN:文件名称
- 'TL:标题
- 'TP:文件类型
- 'OP:true 打开 false 保存
- Function Get_FileName(FN As Variant, TL As Variant, TP As Variant, OP As Boolean, Optional DFLG As Boolean = True)
- Dim ret As Variant
- Dim S_DIR As String
- Dim S_FN As String
- Dim l As Integer
- Dim FILENAME As String
- Dim S_TL As String
- Dim S_TP As String
- Dim strFilter As String
- Get_FileName = "CANCEL"
- S_TL = TL
- S_TP = TP
- If (IsNull(FN) Or (Len(Trim(FN)) = )) Then
- S_DIR = ""
- S_FN = ""
- Else
- l =
- ret =
- Do While (ret > )
- ret = InStr(l, FN, "\")
- If (IsNull(ret)) Then
- S_DIR = ""
- S_FN = ""
- ret =
- End If
- If (ret = ) Then
- S_DIR = Mid(FN, , l - )
- S_FN = Mid(FN, l)
- End If
- l = ret +
- Loop
- End If
- Select Case TP
- Case "TXT"
- strFilter = "TextFile (*.txt)" & vbNullChar & "*.txt" & vbNullChar
- Case "CSV"
- strFilter = "TextFile (*.csv)" & vbNullChar & "*.csv" & vbNullChar
- Case "XLS"
- strFilter = "ExcelFile (*.xls)" & vbNullChar & "*.xls*" & vbNullChar & "TextFile (*.csv)" & vbNullChar & "*.csv" & vbNullChar
- Case "MDB"
- strFilter = "AccessFile (*.mdb)" & vbNullChar & "*.mdb" & vbNullChar
- Case Else
- strFilter = ""
- End Select
- strFilter = strFilter & "All File (*.*)" & vbNullChar & "*.*"
- FILENAME = spFileDlg(strFilter, S_DIR, S_TL, S_TP, OP, S_FN)
- If FILENAME = "CANCEL" Then
- Exit Function
- End If
- ret = InStr(, FILENAME, Chr())
- If (IsNull(ret)) Then
- Exit Function
- Else
- If (ret > ) Then
- FILENAME = Mid(FILENAME, , ret - )
- End If
- End If
- If (OP = False And DFLG) Then
- If (Len(Dir(FILENAME)) > ) Then
- ret = MsgBox("OverWrite. OK?", vbYesNo, "OverWrite")
- If (ret <> vbYes) Then
- Exit Function
- Else
- Err =
- On Error Resume Next
- Kill FILENAME
- On Error GoTo
- If (Err <> ) Then
- ret = MsgBox("OverWrite Error. File Opened? ", , "OverWriteError")
- Exit Function
- End If
- End If
- End If
- End If
- Get_FileName = FILENAME
- End Function
comdlg32.dll的更多相关文章
- Delphi之DLL知识学习1---什么是DLL
DLL(动态链接库)是程序模块,它包括代码.数据或资源,能够被其他的Windows 应用程序共享.DLL的主要特点之一是应用程序可以在运行时调入代码执行,而不是在编译时链接代码,因此,多个应用程序可以 ...
- 详细介绍dll文件是什么
DLL是Dynamic Link Library的缩写,意为动态链接库.DLL文件一般被存放在C:WindowsSystem目录下.DLL是一个包含可由多个程序同时使用的代码和数据的库. 在Wind ...
- [DLL] Dynamic link library (dll) 的编写和使用教程
前一阵子,项目里需要导出一个DLL,但是导出之后输出一直不怎么对,改了半天才算改对...读了一些DLL教程,感觉之后要把现在的代码导出,应该还要花不少功夫...下面教程参照我读的3个教程写成,所以内容 ...
- windows系统中的dll的作用详细解释
什么是.DLL文件? DLL 是一个包含可由多个程序同时使用的代码和数据的库.例如,在 Windows 操作系统中,Comdlg32 DLL 执行与对话框有关的常见函数.因此,每个程序都可以使用该 D ...
- .Net,Dll扫盲篇,如何在VS中调试已经编译好的dll?
什么是Dll? DLL 是一个包含可由多个程序同时使用的代码和数据的库. 例如,在 Windows 操作系统中,Comdlg32 DLL 执行与对话框有关的常见函数.因此,每个程序都可以使用该Dll中 ...
- 在Visual Studio中使用C++创建和使用DLL
[什么是DLL(动态链接库)?] DLL是一个包含可由多个程序同时使用的代码和数据的库.例如:在Windows操作系统中,Comdlg32 DLL执行与对话框有关的常见函数.因此,每个程序都可以使用该 ...
- 动态链接库 —— Dll 基础
1. DLL 的初识 在 windows 中,动态链接库是不可缺少的一部分,windows 应用程序程序接口提供的所有函数都包含在 DLL 中,其中有三个非常重要的系统 DLL 文件,分别为 Kern ...
- 【1】基于OpenCV的DLL动态库隐式连接
1DLL的作用 DLL是一个包含可由多个程序同时使用的代码和数据的库.例如:在Windows操作系统中,Comdlg32 DLL执行与对话框有关的常见函数.因此,每个程序都可以使用该DLL中包含的功能 ...
- 每日扫盲(二):xxx.dll文件的作用
DLL,dynamic-link library 动态链接库.我们看他的说明,是应用程序扩展.DLL内是一些程序的功能.由于使用静态链接库(static LIBrary,LIB)会使主程序变得臃肿,并 ...
随机推荐
- 简单的事件处理类Event
class Event{ constructor(){ this.handlers=[] } on(type,fn){ //订阅事件 if(!this.handlers[type]){ this.ha ...
- Oracle OCP之硬解析在共享池中获取内存锁的过程
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/38684819 1.获得library cache Latch (1)在父游标的名柄没有找到 ...
- sgu101Domino
给你一些边,假设存在欧拉路径就打出来 我的代码例如以下: #include<iostream> #include<cstring> using namespace std; i ...
- Cocos2d-HTML5搭载nodejs express3
源代码 已经上传到github Cocos2d-HTML5 入门第一天搭载了express3 server.Cocos2d-html5配置改了不少路径,改得有点乱. 今天又重搭了一遍server,力求 ...
- Codeforces Round #336 (Div. 2) 608C Chain Reaction(dp)
C. Chain Reaction time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- [Java] 实验6參考代码
1. 大家的.java程序都须要在一个"缺省包"(default package)下编写\执行\提交,不要去命名新的package - 系统不支持package contr ...
- Python基础--webbrowser
非常多人,一提到Python,想到的就是爬虫.我会一步一步的教你怎样爬出某个站点. 今天就先介绍一下webbrowser,这个词您肯定不会陌生.对,就是浏览器. 看看Python中对webbrowse ...
- 第14章4节《MonkeyRunner源代码剖析》 HierarchyViewer实现原理-装备ViewServer-port转发
在初始化HierarchyViewer的实例过程中,HierarchyViewer会调用自己的成员方法setupViewServer来把ViewServer装备好,那么我们这里先看下这种方法: 39 ...
- Android 自带Base64加密解密
Android项目引用不到以下两个java类 import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; Android有自己的base ...
- Android开发常用框架汇总
作为一名程序猿,好的工具会让你在搬运工的道路上越走越远.以下框架是AC在开发过程中经常会使用到的一些好的框架.列在这里做一个小小的总结,包含但不限于此. 响应式编程 RxJava https://gi ...