看看对你有帮助吗!
http://www.csdn.net/develop/read_article.asp?id=12675

解决方案 »

  1.   

    是不是申明API的时候?
    比如:
    BOOL 函数名(char* lpBuffer);申明成:
    Declare Function 函数名 Lib dll名(ByVal lpBuffer As String) As Long
      

  2.   

    返回值是Char指针,那在VB就作String处理了
      

  3.   

    可能要设缓冲区吧
     调用时:
    dim a as string *255  (假设255足够)
    dim b as long
    b = 函数名 (a)
      

  4.   

    把分都给我好了,先建立一个结点类,起后继指针类型为char....再建立一个接点类型的链表用于存储c中动态库的char类型的指针结点...
      

  5.   

    字符串指针是一个特例,没有通用代表性
    如果想真正明白VB中的指针
    还是应该看一下AdamBear的文章
      

  6.   

    如果是指针,就当long。
    然后再去读内存就ok.
      

  7.   

    [名称]           VB中使用指针[数据来源]       Tom Quantum[内容简介]       空[源代码内容]INTRODUCTION Something that C++ programmers have long been using is the pointer. These magical creatures are variables that literally hold memory locations. This means that instead of holding content, the variable points to a memory location (that is usually a variable) that contains data. I, not being fluent in C++, am not sure if C++ allows you to modify the value of a pointer, but if you could, you would instantly change the memory location that the pointer points to! But enough talk. Let's begin. ADVANTAGES & DISADVANTAGES OF POINTERS Before we delve into pointers, I would like to discuss why we should use pointers. After all, that's why we have ByRef. Well, one reason is that using pointers reduces memory consumption, and increases performance and efficiency. For example, passing a variable using ByVal uses a lot more memory than ByRef, because ByVal actually forces VB to create a new variable, and copy the contents of the original variable into the new one. But if we already have ByRef, why venture into using pointers? Well, pointers are flexible. Change the memory location the pointer points to, and the pointer points to that location, and using the Win32 API function CopyMemory will allow us to implant the contents of that memory location into the variable of our choice. In fact, some other Win32 API functions strictly require the use of memory locations! At the same time, pointers have disadvantages as well. You trade performance for stability. Your programs become harder to read, maintain, and less stable if you switch to using pointers. For example, you might accidentally point to a memory location that isn't in use by your program! You also leave VB's safe and cozy debugging environment and enter the crash zone. VB won't tell you that a pointer points to a memory location out of your program's memory bounds, and you will only be alerted by either a variable containing nothing, or a crash. It took me at least 2 hours staring at my demo app (details later) until I found out why it didn't work. So if you're gonna use pointers, good luck! DECLARING A POINTER Before we can use a pointer, we need to declare it first. A function that has long been shrouded in secrecy is the VarPtr function. It used to be in early versions of VB, but it was available only as an API call. Now, it is part of the VB language. Here's how you use it: Dim F as Integer 
    Dim L as Long F = 4 
    L = VarPtr(F) F is the name of the variable, and L, after calling VarPtr, contains the memory location of the variable. You can edit the value if you want. USING A POINTER There are many ways to use a pointer. One way is to hand it over to a Win32 API call such as CopyMemory. This is the Declare statement for CopyMemory: Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Destination and Source can either be a variable (use ByRef) or a memory location (use ByVal). For example: CopyMemory ByVal TML, ByVal SML, 2 'Or CopyMemory NewNum, Num, 2 Here, TML and SML are pointers, and NewNum and Num are the variables they point to, respectively. Note that you use ByVal when using pointers, and ByRef (default) when using variable names. You can even mix the two, like this: CopyMemory ByVal TML, Num, 2 CopyMemory NewNum, ByVal SML, 2 Use the first one if you know the variable name of the source, and use the second one if you know the variable name of the destination. The Length argument specifies the number of bytes that you want to be transferred. I use 2, because there are two bytes in an integer (the last time I checked). I would really appreciate it if someone sends me a table listing the amount of bytes each data type in VB takes up. EXAMPLE My demo program is finally out of the infirmary. It took about a minute to make, and 1hour, 59 minutes to debug. All it does is prompt you for a number, then it uses CopyMemory to copy the value to another variable using variable pointers. Check it out! It is quite simple, and I know it isn't the best example around. I was originally going to make a sorting program, but it proved too difficult to debug. So this is what I used instead. The first step I took was create the project structure, which consists of a project (duh), a form, and a module. The code module contains the Win32 API call to CopyMemory. The form consists of a few labels; I won't cover them here because you can check the code. I'll then dissect the code for the form one block at a time. Private Sub cmdTest_Click() Please don't tell me you don't know what this does! Dim Num As Integer   'Source Variable 
    Dim NewNum As Integer 'Target variable 
    Dim SML As Long   'Source Memory Location 
    Dim TML As Long   'Target Memory Location I declared the variables. We're nearing the meat of the program! 'Error Handling 
    If Not IsNumeric(txtVal.Text) Then 
      MsgBox "X not numeric!" 
      Exit Sub 
    End If 
    If Val(txtVal.Text) > 32767 Then 
      MsgBox "X must be less than 32767!" 
      Exit Sub 
    End If 
    If Val(txtVal.Text) < -32768 Then 
      MsgBox "X must be greater than -32768!" 
      Exit Sub 
    End If 'Assign values 
    Num = Val(txtVal.Text) 
    NewNum = 0 The preceding was some error checking, to ensure that X is within the boundaries of an integer, and then after that, I assigned X to that value. 'Get Memory Locations 
    SML = VarPtr(Num) 
    TML = VarPtr(NewNum) 
       
    'CopyMemory 
    CopyMemory NewNum, ByVal SML, 2 'Or CopyMemory NewNum, Num, 2 This code is the heart of the program. It simply assigns SML and TML the memory locatiosn of Num and NewNum. Then, it uses CopyMemory to copy data from Num to NewNum. I could have used the code inside the comments, but I wanted to demonstrate what you could do with variable pointers. 'Display Results 
    lblMemLoc.Caption = "Source Memory Location: " & Str(SML) 
    lblNewMemLoc.Caption = "Target Memory Location: " & Str(TML) 
    lblNewVal.Caption = "Value of target after CopyMemory: " & Str(NewNum) After all that, I simply displayed the results. And that's that! CONCLUSION Pointers used to belong only in the C++ realm. But with the discovery of VarPtr, and the use of CopyMemory, Visual Basic now has this feature. I hope I have documented this feature well. But pointers can be hard to manage, if you're not careful. So harness this power well... Good luck! ====================================== Tom Quantum 
    Please leave comments! I appreciate any kind of feedback. And if you find this useful, I would appreciate it if you vote for it. That way, I will make better articles in the future.     以上代码保存于: SourceCode Explorer(源代码数据库)
               复制时间: 2003-1-7 20:35:58
               软件版本: 1.0.816
               软件作者: Shawls
               个人主页: Http://Shawls.Yeah.Net
                 E-Mail: [email protected]
                     QQ: 9181729