如何将PowerBASIC类型转换为VB6类型?

时间:2009-07-21 15:29:50

标签: vb6 types

这些类型来自FastCGI Dll Library (with SIGTERM handler) for Windows Web Servers的演示,并使用PowerBASIC编写。我正在尝试将它们转换为VB6(还发现了如何call a CDECL DLL from VB6)。

    ' Structures
    TYPE FCGX_STREAM
      pData           AS DWORD            ' Pointer to the first byte of data   
      LenStored       AS DWORD            ' Bytes Total data stored - up to 4.2GB 
      Capacity        AS DWORD            ' Bytes Total available   - up to 4.2GB  
      CurPos          AS DWORD            ' Current Position within the buffer of the next byte to read, as an offset from pData

      Reserved        AS STRING*12        ' Opaque Variables
    END TYPE ' 28 bytes  


    TYPE FCGX_REQUEST 
      Version         AS LONG             ' Dll Version Number * 1000 = %FCGI_VERSION        
      ReqCount        AS LONG             ' Request Counter 

      Role            AS LONG             ' FastCGI Role
      ConnFlags       AS LONG             ' Connection flags - zero = application closes connection after responding

      ReqMethod       AS LONG             ' Request HTTP Method - Code 1 - 8
      ContLen         AS LONG             ' CONTENT_LENGTH - Length of POST data sent (in the pInStream Data String)   
      pzQuery         AS ASCIIZ PTR       ' Pointer to ASCIIZ (Null Terminated) QUERY_STRING (Values Only) - Always a valid pointer

      nParam          AS LONG             ' Number of Request Params in the array                                  
      envp            AS DWORD PTR        ' Pointer to Array of Request Parameters  

      pIn             AS FCGX_STREAM PTR  ' Pointer to a String Builder object
      pOut            AS FCGX_STREAM PTR  ' Pointer to a String Builder object
      pErr            AS FCGX_STREAM PTR  ' Pointer to a String Builder object                                          

      pzLastErr       AS ASCIIZ PTR       ' Pointer to ASCIIZ String containing Last Error description

      Reserved        AS STRING*108       ' Opaque Variables
    END TYPE ' 160 bytes

我的问题在于理解如何获取ASCIIZ PTRFCGX_STREAM PTRDWORD PTR项中存储的信息。

2 个答案:

答案 0 :(得分:3)

我多年没有使用VB6了,所以请以下面的信息以健康的怀疑态度。但是,如果我今天遇到这个问题,那就是我开始的地方。

由于您在VB6中工作,我将假设这是32位代码。

PTR类型似乎是指向其他内容分配的内存块的指针。要访问该内存,您需要取消引用指针。

所有PTR值都是32位,因此当您为此创建VB6结构时,请放置DWORD或LONG或VB6 32位值。

要取消引用指针,您需要调用Windows API函数RtlMoveMemory,如here所述。 RtlMoveMemory的所有三个参数都是32位值。

答案 1 :(得分:1)

  • Jim's answer看起来不错。我还建议在编写要从VB调用的C DLL时查看Microsoft advice。最初与VB5一起发布但仍与VB6相关。它解释了结构包装等。
  • EDIT。另外值得一看:VB6大师Karl Peterson discusses如何处理VB6中包含指针的结构。