请教 64位 OPENFILENAME
<p>Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long</p><p></p><p>Type OPENFILENAME</p><p> lStructSize As Long</p><p> hwndOwner As Long</p><p> hInstance As Long</p><p> lpstrFilter As String</p><p> lpstrCustomFilter As String</p><p> nMaxCustFilter As Long</p><p> nFilterIndex As Long</p><p> lpstrFile As String</p><p> nMaxFile As Long</p><p> lpstrFileTitle As String</p><p> nMaxFileTitle As Long</p><p> lpstrInitialDir As String</p><p> lpstrTitle As String</p><p> flags As Long</p><p> nFileOffset As Integer</p><p> nFileExtension As Integer</p><p> lpstrDefExt As String</p><p> lCustData As Long</p><p> lpfnHook As Long</p><p> lpTemplateName As String</p><p>End Type</p>
<div>Function GetTextFile() As String</div><div> Dim ofn As OPENFILENAME</div><div> Dim rtn As String</div><div> ofn.lStructSize = Len(ofn)</div><div> ofn.hwndOwner = CLng(Application.hwnd)</div><div> 'ofn.hInstance = Application.hwnd</div><div> ofn.lpstrFilter = "text Files (*.txt)" & Chr(0) & "*.txt" & Chr(0)</div><div> ofn.lpstrFile = Space(254)</div><div> ofn.nMaxFile = 255</div><div> ofn.lpstrFileTitle = Space(254)</div><div> ofn.nMaxFileTitle = 255</div><div> ofn.lpstrInitialDir = "C:/"</div><div> ofn.lpstrTitle = "打开文件"</div><div> ofn.flags = 6148</div><div> rtn = GetOpenFileName(ofn)</div><div> </div><div> If rtn >= 1 Then</div><div> GetTextFile = ofn.lpstrFile</div><div> Else</div><div> </div><div> End If</div><div> </div><div>End Function</div>想用以上代码在64位的win7上打开文本框,不知道为什么怎么也用不了,求大神指导!万分感谢!
楼主努力! 将其中的“Application.hwnd”全改为“ThisDrawing.HWnd32”试试!
页:
[1]