本文介绍了需要帮助将vb6代码移植到VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些vb6代码移植到vb.net,并且代码行中的一个对象在使用之前没有分配值这里是代码



I'm trying to port some vb6 code to vb.net and one object in a line of code is not assigned a value before it's used Here's the code

Public Function GetFileFullPath(ByVal hFile As Long) As String
    Dim objName         As UNICODE_STRING
    Dim hHeap           As Long
    Dim dwSize          As Long
    Dim dwDriversSize   As Long
    Dim pName           As Long
    Dim ntStatus        As Long
    Dim i               As Long
    Dim strDrives       As String
    Dim strArray()      As String
    Dim strDrive        As String
    Dim strTmp          As String
    Dim strTemp         As String

    hHeap = GetProcessHeap
    pName = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, &H1000)
    ntStatus = NtQueryObject(hFile, ObjectNameInformation, pName, &H1000, dwSize)
    If (NT_SUCCESS(ntStatus)) Then
        i = 1
        Do While (ntStatus = STATUS_INFO_LEN_MISMATCH)
            pName = HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pName, &H1000 * i)
            ntStatus = NtQueryObject(hFile, ObjectNameInformation, pName, &H1000, ByVal 0)
            i = i + 1
        Loop
    End If
    HeapFree hHeap, 0, pName
    strTemp = String$(512, Chr$(0))
    lstrcpyW strTemp, pName + Len(objName)





在最后一行,objName尚未初始化,然后我得到警告'objName在分配之前使用一个值。



你认为作者是指Len(pName)吗?



谢谢



我尝试过:



我有一个使用objName的函数。其中大部分都包含在帖子中。



On the very last line, objName has not been initialized and I get then warning 'objName is used before it has been assigned a value.

Do you think the author meant Len(pName) ?

thanks

What I have tried:

I have a function that uses objName. Most of it is included in the post.

推荐答案






在最后一行,objName尚未初始化,然后我得到警告'objName is在被赋予价值之前使用。



你认为作者是指Len(pName)吗?



谢谢



我尝试过:



我有一个使用objName的函数。其中大部分都包含在帖子中。



On the very last line, objName has not been initialized and I get then warning 'objName is used before it has been assigned a value.

Do you think the author meant Len(pName) ?

thanks

What I have tried:

I have a function that uses objName. Most of it is included in the post.


这篇关于需要帮助将vb6代码移植到VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 18:48