ファイルマッピングするには

解決


VBむずかし  2005-05-31 06:47:23  No: 122064

VB.NETでメモリーマップトファイルを使ってスレッド間で巨大ファイル
を共有したいのですが、どうしてもハンドルが帰ってきません
0=CreateFileMapping()
となってしまいます。
よろしくご教授ください。

=======================================================

Dim hFileMap, hFile As Integer
Dim filename As String

filename = "new.txt"

hFile = CreateFile(filename, GENERIC_WRITE \ GENERIC_READ, _
        0, 0, OPEN_EXISTING, 0, 0)<==成功(3592等の値)

hFileMap = CreateFileMapping(hFile, 0, PAGE_READWRITE, _
            0, 0, "test")<==常に”0”失敗

=============================

Public Const GENERIC_READ As Integer = &H80000000 '読み込み
Public Const GENERIC_WRITE As Integer = &H40000000 '書き込み
Public Const GENERIC_WRITECOPY As Integer = &H10000000 '書き込み
Public Const OPEN_EXISTING As Short = 3 'ファイルをオープンする。
Public Const OPEN_ALWAYS As Short = 4 

    Declare Function CreateFile Lib "KERNEL32" Alias "CreateFileA"_
     (ByVal lpFileName As String, _
      ByVal dwDesiredAccess As Integer,_
      ByVal dwShareMode As Integer, _
      ByVal lpSecurityAttributes As Integer, _
      ByVal dwCreationDisposition As Integer, _
      ByVal dwFlagsAndAttributes As Integer, _
      ByVal hTemplateFile As Integer) As Integer
    Declare Function CreateFileMapping Lib "KERNEL32" Alias "CreateFileMappingA"
     (ByVal hFile As Integer, _
     ByVal lpFileMappigAttributes As Integer, _
     ByVal flProtect As Integer, _
     ByVal dwMaximumSizeHigh As Integer, _
     ByVal dwMaximumSizeLow As Integer, _
     ByVal lpName As String) As Integer


ガッ  2005-05-31 07:45:39  No: 122065

とりあえず気になった点。
> GENERIC_WRITE \ GENERIC_READ
は"GENERIC_WRITE OR GENERIC_READ"(または"GENERIC_WRITE + GENERIC_READ")かも。


魔界の仮面弁士  2005-05-31 18:53:55  No: 122066

とりあえず、このあたりとか。

http://www.gdncom.jp/general/bbs/ShowPost.aspx?PostID=29298


VBむずかし  2005-05-31 20:06:48  No: 122067

ガッさん魔界の仮面弁士さんありがとうございました。
無事に動きました。
それにしてもやっぱり「VBむずかし」ですね。


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加