' 定義部分 Public Structure RAPIINIT Dim cbSize As Integer Dim heRapiInit As Integer Dim hrRapiInit As Integer End Structure
Public Const GENERIC_READ = &H80000000 Public Const GENERIC_WRITE = &H40000000
Public Declare Function CeRapiInitEx Lib "rapi.dll" (ByRef pRapiInit As RAPIINIT) As Integer
Public Declare Function CeCreateFile Lib "rapi.dll" ( _ 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
Public Declare Function CeCloseHandle Lib "rapi.dll" (ByVal hObject As Integer) As Boolean
Public Declare Function CeRapiUninit Lib "rapi.dll" () As Integer
''実行部分 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stRapiInit As New RAPIINIT stRapiInit.cbSize = Len(stRapiInit) stRapiInit.heRapiInit = 0 stRapiInit.hrRapiInit = 0
分類:[.NET]
はじめまして。Akiと申します。
環境は
・VB2008
・.NET Framework 3.5 SP1
です。
PDAにあるファイルをRAPIを使用し取得したいのですがうまくいきません。
以前この掲示板にあった質問を見たのですが同じようにやっているつもりなのですが、どうにもうまくいかず、困っています。皆様の知恵をお貸しください。
取りあえず、VB2008で新しいプロジェクトを立ち上げ、下記のような
プログラムにしましたが、CECreateFileでハンドルが取得できません。
大変お手数ですが、ご教授お願いいたします。
Public Class Form1
' 定義部分
Public Structure RAPIINIT
Dim cbSize As Integer
Dim heRapiInit As Integer
Dim hrRapiInit As Integer
End Structure
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
Public Declare Function CeRapiInitEx Lib "rapi.dll" (ByRef pRapiInit As RAPIINIT) As Integer
Public Declare Function CeCreateFile Lib "rapi.dll" ( _
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
Public Declare Function CeCloseHandle Lib "rapi.dll" (ByVal hObject As Integer) As Boolean
Public Declare Function CeRapiUninit Lib "rapi.dll" () As Integer
''実行部分
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stRapiInit As New RAPIINIT
stRapiInit.cbSize = Len(stRapiInit)
stRapiInit.heRapiInit = 0
stRapiInit.hrRapiInit = 0
Dim Result As Integer
Dim hFile As Integer
Result = CeRapiInitEx(stRapiInit)
Dim FilePath As String = "\My Documents\test.txt"
hFile = CeCreateFile(FilePath, GENERIC_READ Or GENERIC_WRITE, 1, 0, 3, 0, 0)
Result = CeCloseHandle(hFile)
Result = CeRapiUninit()
End Sub
End Class