当使用“NetApiBufferFree”时,VB6 exe崩溃在win7 [英] VB6 exe crash when is using "NetApiBufferFree" in win7

查看:101
本文介绍了当使用“NetApiBufferFree”时,VB6 exe崩溃在win7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在VB6中有一个小应用程序搜索SQL服务器。

I have a little application in VB6 which searchs the SQL servers.

Private Sub getSqlServersWithNetApi()

    On Error GoTo getSqlServersWithNetApi_Error



    Dim netStatusRet As Long

    Dim entriesread As Long

    Dim totalentries As Long

    Dim bufptr As Long

    Dim level As Long

    Dim prefmaxlen As Long

    Dim lType As Long

    Dim i As Long

    Dim sv100 As SERVER_INFO_100



    level = 100                '使用SERVER_INFO_100 结构

    prefmaxlen = -1



    lType = SV_TYPE_SQLSERVER

    netStatusRet = NetServerEnum(ByVal 0&,level,bufptr,prefmaxlen,entriesread,totalentries,lType,ByVal 0&,ByVal 0&)



   如果netStatusRet = NERR_Success或netStatusRet = ERROR_MORE_DATA则为
     对于i = 0至条目读取 - 1

          RtlMoveMemory sv100,ByVal bufptr,Len(sv100)

          lstSQLServers.AddItem PointerToWStr(sv100.Name)

          bufptr = bufptr + Len(sv100)

     接下来我是
   结束如果

    NetApiBufferFree bufptr



   退出Sub



getSqlServersWithNetApi_Error:  

    LogError TypeName(Me)," getSqlServersWithNetApi()",Err.Description

Private Sub getSqlServersWithNetApi()
   On Error GoTo getSqlServersWithNetApi_Error

   Dim netStatusRet As Long
   Dim entriesread As Long
   Dim totalentries As Long
   Dim bufptr As Long
   Dim level As Long
   Dim prefmaxlen As Long
   Dim lType As Long
   Dim i As Long
   Dim sv100 As SERVER_INFO_100

   level = 100                 ' use SERVER_INFO_100  structures
   prefmaxlen = -1

   lType = SV_TYPE_SQLSERVER
   netStatusRet = NetServerEnum(ByVal 0&, level, bufptr, prefmaxlen, entriesread, totalentries, lType, ByVal 0&, ByVal 0&)

   If netStatusRet = NERR_Success Or netStatusRet = ERROR_MORE_DATA Then
      For i = 0 To entriesread - 1
         RtlMoveMemory sv100, ByVal bufptr, Len(sv100)
         lstSQLServers.AddItem PointerToWStr(sv100.Name)
         bufptr = bufptr + Len(sv100)
      Next i
   End If
   NetApiBufferFree bufptr

   Exit Sub

getSqlServersWithNetApi_Error:  
   LogError TypeName(Me), "getSqlServersWithNetApi()", Err.Description

End Sub

对于任何操作系统获胜,应用程序工作正常。

For any OS win, the application works fine.

对于OS Win 7,应用程序在"NetApiBufferFree bufptr"行崩溃 - 使用"关闭程序"等。

For OS Win 7, the application crash at line "NetApiBufferFree bufptr" - with "Close the program", etc.

"NetApiBufferFree"已定义

The "NetApiBufferFree" is defined

请你解释一下为什么只发生在Windows 7上?

Could you, please, explain why happend this only for windows 7?

谢谢你,

Gratiela

推荐答案

嗨Gratiela,

此队列与vb.net有关。我担心你关于VB6的话题不适合这里。我将把这个帖子移到主题论坛上。您可以通过以下链接找到正确的论坛:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b

This queue is about vb.net. I’m afraid that your topic about VB6 is unsuitable here. I will move this thread to off topic forum. You can find the correct forum with the help of this link: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b.

很抱歉给您带来不便,祝您有个愉快的一天。

Sorry for any inconvenience and have a nice day.


这篇关于当使用“NetApiBufferFree”时,VB6 exe崩溃在win7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆