Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过WinCE上的VBA获取USB驱动器名称_Vba_Windows Ce_Drive - Fatal编程技术网

通过WinCE上的VBA获取USB驱动器名称

通过WinCE上的VBA获取USB驱动器名称,vba,windows-ce,drive,Vba,Windows Ce,Drive,我需要在Windows CE上通过VBA获取USB驱动器的名称 在Win 7上,Usb驱动器称为“我的拇指驱动器”,在Win CE上,我将其视为“硬盘2”。有没有办法读取真实的拇指名称并将其存储在变量中 FSO(文件系统对象)在Win CE上不可用 ----------------------编辑--------------------------- 另一种方法是检索txt文件的修改日期,该文件仍在Win CE上的VBA中。(创建或保存文件的日期,未访问。)尝试此操作。在Sub Sample()

我需要在Windows CE上通过VBA获取USB驱动器的名称

在Win 7上,Usb驱动器称为“我的拇指驱动器”,在Win CE上,我将其视为“硬盘2”。有没有办法读取真实的拇指名称并将其存储在变量中

FSO(文件系统对象)在Win CE上不可用

----------------------编辑---------------------------


另一种方法是检索txt文件的修改日期,该文件仍在Win CE上的VBA中。(创建或保存文件的日期,未访问。)

尝试此操作。在
Sub Sample()中传递文件名


USB名称或驱动器号?在我的原始帖子中添加了一个替代解决方案。我从未与Win CE合作过。你能确认它是否支持API吗?我也是第一次,所以我不确定。我可以添加引用,但只有现有的/受支持的引用,而FSO不在其中。好的,让我发布一个API示例,然后您可以为我测试它?顺便说一句,你知道文件的名称和完整路径吗?我得到一个错误(德语)。类似于第一个kernel32声明中的“等待数据类型,例如整数”之类的问题,可以通过对声明重新排序来解决。正在将代码上载到plc。。将在Win 7上报告soonWorks罚款,但在CE上我收到以下错误:
18.12.2013 16:14:28系统:执行基本脚本“Button679”时出错(第14行,偏移量9):需要一个变量名。
如果没有看到您的代码,我就不知道错误是什么意思,就像我说的,我从来没有使用过Win Cet。我拥有的唯一代码就是您给我的代码。。只是对函数和声明进行了重新排序。正在使用引发错误的当前代码更新我的主要帖子。。
Option Explicit

Private Declare Function OpenFile Lib "kernel32" _
(ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, _
ByVal wStyle As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Declare Function GetFileTime Lib "kernel32" _
(ByVal hFile As Long, lpCreationTime As FILETIME, _
lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long

Private Declare Function FileTimeToSystemTime Lib _
"kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long

Private Const OF_READ = &H0
Private Const OFS_MAXPATHNAME = 128

Private Type OFSTRUCT
    cBytes As Byte
    fFixedDisk As Byte
    nErrCode As Integer
    Reserved1 As Integer
    Reserved2 As Integer
    szPathName(OFS_MAXPATHNAME) As Byte
End Type

Private Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type

Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type

Sub Sample()
    Debug.Print GetFileCreatedDateAndTime("c:\Sample.txt")
End Sub

Private Function GetFileCreatedDateAndTime(sFile As String) As String
    Dim hFile As Long, rval As Long
    Dim buff As OFSTRUCT
    Dim f1Time As FILETIME, f2Time As FILETIME, f3Time As FILETIME
    Dim stime As SYSTEMTIME

    GetFileCreatedDateAndTime = "Unable To retrieve details"

    hFile = OpenFile(sFile, buff, OF_READ)
    If hFile Then
        rval = GetFileTime(hFile, f1Time, f2Time, f3Time)
        rval = FileTimeToSystemTime(f1Time, stime)

        GetFileCreatedDateAndTime = _
        "Created on " & _
        stime.wDay & "-" & stime.wMonth & "-" & stime.wYear & _
        Chr(13) & _
        "Created at " & _
        stime.wHour & ":" & stime.wMinute & ":" & stime.wSecond
    End If
    rval = CloseHandle(hFile)
End Function