首页 新闻 会员 周边 捐助

vb6 文件打开对话框 无边框 显示不完全

0
悬赏园豆:10 [已解决问题] 解决于 2013-10-06 15:11

下面这个函数为什么执行后会有问题,请问如何修正,当然要能实现这个功能啊?

Option Explicit
Private Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type
Private Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile As Long, lpFileMappigAttributes As SECURITY_ATTRIBUTES, ByVal flProtect As Long, ByVal dwMaximumSizeHigh As Long, ByVal dwMaximumSizeLow As Long, ByVal lpName As String) As Long
Private Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Private Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Private Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Private Const SECTION_MAP_READ = &H4
Private Const FILE_MAP_READ = SECTION_MAP_READ
Private Const SECTION_MAP_WRITE = &H2
Private Const FILE_MAP_WRITE = SECTION_MAP_WRITE
Private Const PAGE_READWRITE = &H4

Dim m_hMemShare As Long
Dim m_lpdata As Long

Public Function CreateRestCallerSharedMemory()
    Dim hMemShare As Long
    Dim mAttr As SECURITY_ATTRIBUTES
    Dim data As Long
    Dim lpData As Long
    data = GetCurrentProcessId
    hMemShare = CreateFileMapping(&HFFFFFFFF, mAttr, PAGE_READWRITE, 0, LenB(data), "Test")
    If hMemShare = 0 Then
        Debug.Print "无法创建映像文件,创建映像数据失败!"
        Exit Function
    End If
    m_hMemShare = hMemShare
    lpData = MapViewOfFile(hMemShare, FILE_MAP_WRITE, 0, 0, LenB(data))
    If lpData = 0 Then
        Debug.Print "映像文件到当前进程失败!"
        Exit Function
    End If
    m_lpdata = lpData
    CopyMemory ByVal lpData, data, LenB(data)
End Function

Private Sub Form_Load()
    CreateRestCallerSharedMemory //执行这句后就有问题了
    CommonDialog1.ShowOpen
End Sub
空明流光的主页 空明流光 | 初学一级 | 园豆:111
提问于:2013-10-05 19:23
< >
分享
最佳答案
0

显示不完全最好能截个图就更能表达清楚了

收获园豆:10
I,Robot | 大侠五级 |园豆:9783 | 2013-10-06 00:44

重启了下就好了,因为用的虚拟机开发,长时间没有重启,可能刚好有些地方有内存泄漏吧

空明流光 | 园豆:111 (初学一级) | 2013-10-06 15:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册