Home > Software engineering >  The form showed abnormal?
The form showed abnormal?

Time:10-25

 
The following function can cause the pop-up file open dialog displays incomplete, please if how to fix?
This function is to set up a Long memory mapping file, but there seems to be a memory leak, could you tell me how to write a Long memory mapping file?
Option Explicit
Private Type SECURITY_ATTRIBUTES
NLength As Long
The lpSecurityDescriptor As Long
BInheritHandle As Long
End Type
Private Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile, As Long As lpFileMappigAttributes 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=& amp; H4
Private Const FILE_MAP_READ=SECTION_MAP_READ
Private Const SECTION_MAP_WRITE=& amp; The H2
Private Const FILE_MAP_WRITE=SECTION_MAP_WRITE
Private Const PAGE_READWRITE=& amp; H4

Dim m_hMemShare As Long
Dim m_lpdata As Long

The Public Function CreateRestCallerSharedMemory ()
Dim hMemShare As Long
Dim mAttr As SECURITY_ATTRIBUTES
Dim data As Long
Dim lpData As Long
Data=https://bbs.csdn.net/topics/GetCurrentProcessId
HMemShare=CreateFileMapping (& amp; HFFFFFFFF mAttr, PAGE_READWRITE, 0, LenB (data), "RestCallerShare")
If hMemShare=0 Then
The Debug. Print "unable to create the image file, failed to create the image data!"
The Exit Function
End the If
M_hMemShare=hMemShare
LpData=https://bbs.csdn.net/topics/MapViewOfFile (hMemShare FILE_MAP_WRITE, 0, 0, LenB (data))
If lpData=https://bbs.csdn.net/topics/0 Then
The Debug. Print "image file to the current process failed!"
The Exit Function
End the If
M_lpdata=https://bbs.csdn.net/topics/lpData
CopyMemory ByVal lpData, data, LenB (data)
End the Function

Private Sub Form_Load ()
CreateRestCallerSharedMemory
CommonDialog1. ShowOpen
End Sub
  •  Tags:  
  • API
  • Related