袁绍伦
路人甲
路人甲
  • 注册日期2003-08-08
  • 发帖数654
  • QQ164646905
  • 铜币1336枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1281回复:2

Visual Basic Example of GlobalHandle

楼主#
更多 发布于:2003-09-03 21:47
' These declarations need to be placed in a VB Module (like Module1.bas).
' They are WINAPI calls dealing with Global Handles
Public Const GMEM_MOVEABLE = &H2

Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
 ByVal dwBytes As Long) As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _
 (ByVal lpString1 As Any, _

 ByVal lpString2 As Any) As Long
 :
 :
 :
Private Sub Command1_Click()
 ' The global handle which will contain the actual data.
 Dim GlobalHandle As Long
 ' This temporarily points to the location of the locked
 ' handle's data, so we can copy our data in
 Dim MemoryBlockAddress As Long
 Dim tabifiedData As String
 
 ' Our source data in the correct tab-deliminated form.
 ' In practice, this could come from a text file or some other source.
 ' The Chr() calls are special characters: 9 is a tab, 13 is a carriage

 ' return, and 10 is a linefeed.
 tabifiedData = """NY""" & Chr(9) & "105.40" & Chr(13) & Chr(10) & _
                """MA""" & Chr(9) & "245.13" & Chr(13) & Chr(10) & _
                """AK""" & Chr(9) & "195.30" & Chr(13) & Chr(10) & _
                """CA""" & Chr(9) & "56.65" & Chr(13) & Chr(10) & _
                """WI""" & Chr(9) & "100.00" & Chr(13) & Chr(10)

 ' Allocate space for the handle's data and copy the source data into it
 GlobalHandle = GlobalAlloc(GMEM_MOVEABLE, Len(tabifiedData) + 1)

 MemoryBlockAddress = GlobalLock(GlobalHandle)
    
 lstrcpy MemoryBlockAddress, tabifiedData
 GlobalUnlock GlobalHandle

 Dim ds As Dataset
 ' Now add the dataset to the datasets collection
 Set ds = Map1.Datasets.Add(miDataSetGlobalHandle, GlobalHandle, "TestDS")

 ' And create a simple theme from the data
 ds.Themes.Add
End Sub

喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
he_young
路人甲
路人甲
  • 注册日期2003-09-13
  • 发帖数221
  • QQ
  • 铜币4枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2003-09-19 00:05
嘿嘿,小袁,能在这里碰到你,真是不错
QQ:11716903 email:he_young@163.net ************************************** 不要去想我是谁,因为我在那个你看不到的黑暗角落 我来了,我也会走 就像你来了,你也会走...
举报 回复(0) 喜欢(0)     评分
袁绍伦
路人甲
路人甲
  • 注册日期2003-08-08
  • 发帖数654
  • QQ164646905
  • 铜币1336枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2003-09-19 18:53
河马兄,你真的是 10.1 的生日吗?

我也是,呵呵,真巧,同一天!!

呵呵哈哈哈哈呵呵
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
举报 回复(0) 喜欢(0)     评分
游客

返回顶部