dll的应用,目前还不知道要怎么查看dll里的功能,暂且试着用了一个,

下面的Declare 分32位office软件和64位,如果是64位,要在Declare 后面加上PtrSafe ,定义的Type里的Long也最好写成LongPtr

  1. Option Explicit
  2.  
  3. Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
  4.  
  5. Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
  6.  
  7. Private Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (ByVal lpszFile As String, ByVal lpszTitle As String, ByVal cbBuf As Integer) As Integer
  8.  
  9. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  10.  
  11. Type OPENFILENAME
  12. lStructSize As Long
  13. hwndOwner As Long
  14. hInstance As Long
  15. lpstrFilter As String
  16. lpstrCustomFilter As String
  17. nMaxCustFilter As Long
  18. nFilterIndex As Long
  19. lpstrFile As String
  20. nMaxFile As Long
  21. lpstrFileTitle As String
  22. nMaxFileTitle As Long
  23. lpstrInitialDir As String
  24. lpstrTitle As String
  25. flags As Long
  26. nFileOffset As Integer
  27. nFileExtension As Integer
  28. lpstrDefExt As String
  29. lCustData As Long
  30. lpfnHook As Long
  31. lpTemplateName As String
  32. End Type
  33.  
  34. Const OFN_READONLY = &H1
  35. Const OFN_OVERWRITEPROMPT = &H2
  36. Const OFN_HIDEREADONLY = &H4
  37. Const OFN_NOCHANGEDIR = &H8
  38. Const OFN_SHOWHELP = &H10
  39. Const OFN_ENABLEHOOK = &H20
  40. Const OFN_ENABLETEMPLATE = &H40
  41. Const OFN_ENABLETEMPLATEHANDLE = &H80
  42. Const OFN_NOVALIDATE = &H100
  43. Const OFN_ALLOWMULTISELECT = &H200
  44. Const OFN_EXTENSIONDIFFERENT = &H400
  45. Const OFN_PATHMUSTEXIST = &H800
  46. Const OFN_FILEMUSTEXIST = &H1000
  47. Const OFN_CREATEPROMPT = &H2000
  48. Const OFN_SHAREAWARE = &H4000
  49. Const OFN_NOREADONLYRETURN = &H8000
  50. Const OFN_NOTESTFILECREATE = &H10000
  51. Const OFN_NONETWORKBUTTON = &H20000
  52. Const OFN_NOLONGNAMES = &H40000
  53. Const OFN_EXPLORER = &H80000
  54. Const OFN_NODEREFERENCELINKS = &H100000
  55. Const OFN_LONGNAMES = &H200000
  56.  
  57. Const OFN_SHAREFALLTHROUGH =
  58. Const OFN_SHARENOWARN =
  59. Const OFN_SHAREWARN =
  60.  
  61. Const MAX_PATH =
  62.  
  63. Sub test1105()
  64.  
  65. Debug.Print Get_FileName("D:\lcx\", "我的测试选择", "XLS", True)
  66.  
  67. End Sub
  68.  
  69. 'strFilter = 过滤条件
  70. 'strInitialDir = 文件起始目录
  71. 'strTitle = 标题
  72. 'strDefExt = 过滤条件
  73. 'blOpen = 选择 True 保存 False
  74. Function spFileDlg(strFilter As String, strInitialDir As String, strTitle As String, strDefExt As String, blOpen As Boolean, FN As String)
  75.  
  76. Dim fFileName As OPENFILENAME
  77. Dim strBuff As String
  78. Dim accWnd As Long
  79.  
  80. Dim lngRet As Long
  81.  
  82. accWnd = FindWindow("OMAIN", vbNullString)
  83.  
  84. strBuff = FN & String$(MAX_PATH - LenB(FN), )
  85.  
  86. With fFileName
  87. .lStructSize = LenB(fFileName)
  88. .hwndOwner = accWnd
  89. .hInstance =
  90. .lpstrFilter = strFilter
  91. .nMaxCustFilter = &
  92. .nFilterIndex =
  93. .lpstrFile = strBuff
  94. .nMaxFile = MAX_PATH
  95. .lpstrFileTitle = String$(MAX_PATH, )
  96. .nMaxFileTitle = MAX_PATH +
  97. .lpstrInitialDir = strInitialDir
  98. .lpstrTitle = strTitle
  99. .flags = OFN_HIDEREADONLY
  100. .lpstrDefExt = strDefExt
  101. End With
  102.  
  103. If blOpen = True Then
  104. lngRet = GetOpenFileName(fFileName)
  105. Else
  106. lngRet = GetSaveFileName(fFileName)
  107. End If
  108.  
  109. If lngRet <> Then
  110. spFileDlg = fFileName.lpstrFile
  111. Else
  112. spFileDlg = "CANCEL"
  113. End If
  114.  
  115. End Function
  116.  
  117. 'FN:文件名称
  118. 'TL:标题
  119. 'TP:文件类型
  120. 'OP:true 打开 false 保存
  121. Function Get_FileName(FN As Variant, TL As Variant, TP As Variant, OP As Boolean, Optional DFLG As Boolean = True)
  122.  
  123. Dim ret As Variant
  124. Dim S_DIR As String
  125. Dim S_FN As String
  126. Dim l As Integer
  127. Dim FILENAME As String
  128. Dim S_TL As String
  129. Dim S_TP As String
  130. Dim strFilter As String
  131.  
  132. Get_FileName = "CANCEL"
  133. S_TL = TL
  134. S_TP = TP
  135.  
  136. If (IsNull(FN) Or (Len(Trim(FN)) = )) Then
  137. S_DIR = ""
  138. S_FN = ""
  139. Else
  140. l =
  141. ret =
  142. Do While (ret > )
  143. ret = InStr(l, FN, "\")
  144. If (IsNull(ret)) Then
  145. S_DIR = ""
  146. S_FN = ""
  147. ret =
  148. End If
  149. If (ret = ) Then
  150. S_DIR = Mid(FN, , l - )
  151. S_FN = Mid(FN, l)
  152. End If
  153. l = ret +
  154. Loop
  155. End If
  156.  
  157. Select Case TP
  158. Case "TXT"
  159. strFilter = "TextFile (*.txt)" & vbNullChar & "*.txt" & vbNullChar
  160. Case "CSV"
  161. strFilter = "TextFile (*.csv)" & vbNullChar & "*.csv" & vbNullChar
  162. Case "XLS"
  163. strFilter = "ExcelFile (*.xls)" & vbNullChar & "*.xls*" & vbNullChar & "TextFile (*.csv)" & vbNullChar & "*.csv" & vbNullChar
  164. Case "MDB"
  165. strFilter = "AccessFile (*.mdb)" & vbNullChar & "*.mdb" & vbNullChar
  166. Case Else
  167. strFilter = ""
  168. End Select
  169.  
  170. strFilter = strFilter & "All File (*.*)" & vbNullChar & "*.*"
  171.  
  172. FILENAME = spFileDlg(strFilter, S_DIR, S_TL, S_TP, OP, S_FN)
  173.  
  174. If FILENAME = "CANCEL" Then
  175. Exit Function
  176. End If
  177.  
  178. ret = InStr(, FILENAME, Chr())
  179. If (IsNull(ret)) Then
  180. Exit Function
  181. Else
  182. If (ret > ) Then
  183. FILENAME = Mid(FILENAME, , ret - )
  184. End If
  185. End If
  186.  
  187. If (OP = False And DFLG) Then
  188. If (Len(Dir(FILENAME)) > ) Then
  189. ret = MsgBox("OverWrite. OK?", vbYesNo, "OverWrite")
  190. If (ret <> vbYes) Then
  191. Exit Function
  192. Else
  193. Err =
  194. On Error Resume Next
  195. Kill FILENAME
  196. On Error GoTo
  197. If (Err <> ) Then
  198. ret = MsgBox("OverWrite Error. File Opened? ", , "OverWriteError")
  199. Exit Function
  200. End If
  201. End If
  202. End If
  203. End If
  204.  
  205. Get_FileName = FILENAME
  206.  
  207. End Function

comdlg32.dll的更多相关文章

  1. Delphi之DLL知识学习1---什么是DLL

    DLL(动态链接库)是程序模块,它包括代码.数据或资源,能够被其他的Windows 应用程序共享.DLL的主要特点之一是应用程序可以在运行时调入代码执行,而不是在编译时链接代码,因此,多个应用程序可以 ...

  2. 详细介绍dll文件是什么

     DLL是Dynamic Link Library的缩写,意为动态链接库.DLL文件一般被存放在C:WindowsSystem目录下.DLL是一个包含可由多个程序同时使用的代码和数据的库. 在Wind ...

  3. [DLL] Dynamic link library (dll) 的编写和使用教程

    前一阵子,项目里需要导出一个DLL,但是导出之后输出一直不怎么对,改了半天才算改对...读了一些DLL教程,感觉之后要把现在的代码导出,应该还要花不少功夫...下面教程参照我读的3个教程写成,所以内容 ...

  4. windows系统中的dll的作用详细解释

    什么是.DLL文件? DLL 是一个包含可由多个程序同时使用的代码和数据的库.例如,在 Windows 操作系统中,Comdlg32 DLL 执行与对话框有关的常见函数.因此,每个程序都可以使用该 D ...

  5. .Net,Dll扫盲篇,如何在VS中调试已经编译好的dll?

    什么是Dll? DLL 是一个包含可由多个程序同时使用的代码和数据的库. 例如,在 Windows 操作系统中,Comdlg32 DLL 执行与对话框有关的常见函数.因此,每个程序都可以使用该Dll中 ...

  6. 在Visual Studio中使用C++创建和使用DLL

    [什么是DLL(动态链接库)?] DLL是一个包含可由多个程序同时使用的代码和数据的库.例如:在Windows操作系统中,Comdlg32 DLL执行与对话框有关的常见函数.因此,每个程序都可以使用该 ...

  7. 动态链接库 —— Dll 基础

    1. DLL 的初识 在 windows 中,动态链接库是不可缺少的一部分,windows 应用程序程序接口提供的所有函数都包含在 DLL 中,其中有三个非常重要的系统 DLL 文件,分别为 Kern ...

  8. 【1】基于OpenCV的DLL动态库隐式连接

    1DLL的作用 DLL是一个包含可由多个程序同时使用的代码和数据的库.例如:在Windows操作系统中,Comdlg32 DLL执行与对话框有关的常见函数.因此,每个程序都可以使用该DLL中包含的功能 ...

  9. 每日扫盲(二):xxx.dll文件的作用

    DLL,dynamic-link library 动态链接库.我们看他的说明,是应用程序扩展.DLL内是一些程序的功能.由于使用静态链接库(static LIBrary,LIB)会使主程序变得臃肿,并 ...

随机推荐

  1. 简单的事件处理类Event

    class Event{ constructor(){ this.handlers=[] } on(type,fn){ //订阅事件 if(!this.handlers[type]){ this.ha ...

  2. Oracle OCP之硬解析在共享池中获取内存锁的过程

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/38684819 1.获得library cache Latch (1)在父游标的名柄没有找到 ...

  3. sgu101Domino

    给你一些边,假设存在欧拉路径就打出来 我的代码例如以下: #include<iostream> #include<cstring> using namespace std; i ...

  4. Cocos2d-HTML5搭载nodejs express3

    源代码 已经上传到github Cocos2d-HTML5 入门第一天搭载了express3 server.Cocos2d-html5配置改了不少路径,改得有点乱. 今天又重搭了一遍server,力求 ...

  5. 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 ...

  6. [Java] 实验6參考代码

    1. 大家的.java程序都须要在一个"缺省包"(default package)下编写\执行\提交,不要去命名新的package     - 系统不支持package contr ...

  7. Python基础--webbrowser

    非常多人,一提到Python,想到的就是爬虫.我会一步一步的教你怎样爬出某个站点. 今天就先介绍一下webbrowser,这个词您肯定不会陌生.对,就是浏览器. 看看Python中对webbrowse ...

  8. 第14章4节《MonkeyRunner源代码剖析》 HierarchyViewer实现原理-装备ViewServer-port转发

    在初始化HierarchyViewer的实例过程中,HierarchyViewer会调用自己的成员方法setupViewServer来把ViewServer装备好,那么我们这里先看下这种方法: 39 ...

  9. Android 自带Base64加密解密

    Android项目引用不到以下两个java类 import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; Android有自己的base ...

  10. Android开发常用框架汇总

    作为一名程序猿,好的工具会让你在搬运工的道路上越走越远.以下框架是AC在开发过程中经常会使用到的一些好的框架.列在这里做一个小小的总结,包含但不限于此. 响应式编程 RxJava https://gi ...