真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net與api Vbnet

VB.Net中該怎么調(diào)用windows的API?

1.Windows的API有兩個(gè)版本的,比如ANSI的FindWindowA(),Unicode的FindWindowW()

創(chuàng)新互聯(lián)公司主要從事網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)鄯善,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專(zhuān)業(yè),歡迎來(lái)電咨詢建站服務(wù):18982081108

2.兩種聲明的方式

DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="FindWindow") _

Shared Function FindWindow(ByVal className As String, ByVal windowName As String) As IntPtr

End Function

Declare Auto Function FindWindow Lib "user32.dll" Alias "FindWindow" (ByVal className As String, ByVal windowName As String) As IntPtr

vb.net 怎么聲明API

不會(huì)這個(gè)API,不過(guò)提醒下,.net的API聲明類(lèi)型都為Integer,不是Long

VB.NET中API函數(shù)問(wèn)題

success = WritePrivateProfileStringA改成success = WritePrivateProfileString 另外vc6里的long在vc.net里要換成integer,你這樣調(diào)用會(huì)出錯(cuò)的

VB.net可以調(diào)用API嗎?怎么調(diào)用?比如我要調(diào)用Gditransparentbit函數(shù)怎么寫(xiě)代

(1).使用DllImport特征類(lèi)來(lái)申明Windows API函數(shù):

下面是在Visual Basic .Net中使用DllImport特征類(lèi)申明二個(gè)Windows API函數(shù)的具體示例:

'函數(shù)ExtractIcon,其功能是是從指定文件的指定位置導(dǎo)出圖標(biāo)的Windows句柄。

< System.Runtime.InteropServices.DllImport ( "Shell32.dll" , EntryPoint := "ExtractIcon" ) > _

Public Function _

ExtractIcon ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As UInt32 ) As System.IntPtr

End Function

'函數(shù)Icon_Num,其功能是獲得指定文件中的圖標(biāo)數(shù)目

< System.Runtime.InteropServices.DllImport ( "Shell32.dll" , EntryPoint := "ExtractIcon" ) > _

Public Function _

Icon_Num ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As Integer ) As Integer

End Function

在使用DllImport特征類(lèi)申明Windows API函數(shù)時(shí),如果申明的函數(shù)名稱(chēng)和函數(shù)的入口點(diǎn)相同,則可以在申明Windows API函數(shù)時(shí),省略定義函數(shù)入口點(diǎn)對(duì)應(yīng)的代碼,即EntryPoint對(duì)象字段對(duì)應(yīng)的代碼,這樣聲明ExtractIcon函數(shù)的代碼也可以簡(jiǎn)化為如下所示:

< System.Runtime.InteropServices.DllImport ( "Shell32.dll" ) > _

Public Function _

ExtractIcon ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As UInt32 ) As System.IntPtr

End Function

(2).使用“Declare”語(yǔ)句來(lái)申明Windows API函數(shù):

使用“Declare”語(yǔ)句的確比使用DllImport特征類(lèi)要簡(jiǎn)單了許多,下面是在Visual Basic .Net中使用“Declare”語(yǔ)句來(lái)聲明上述二個(gè)Windows API函數(shù)的具體方法:

Declare Auto Function ExtractIcon Lib "Shell32.dll" Alias "ExtractIcon" ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As UInt32 ) As System.IntPtr

'聲明ExtractIcon函數(shù)

Declare Auto Function Icon_Num Lib "Shell32.dll" Alias "ExtractIcon" ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As Integer ) As Integer

'聲明Icon_Num函數(shù)

在Visual Basic .Net中聲明Windows API函數(shù)時(shí),“Declare”語(yǔ)句中Alias關(guān)鍵字的作用相當(dāng)于使用DllImport特征類(lèi)中的EntryPoint對(duì)象字段。同樣在使用“Declare”語(yǔ)句聲明Windows API函數(shù)時(shí),如果聲明的函數(shù)和函數(shù)的入口點(diǎn)相同,也可以省略Alias關(guān)鍵字對(duì)應(yīng)的代碼,所以ExtractIcon函數(shù)也可以簡(jiǎn)化為如下:

Declare Auto Function ExtractIcon Lib "Shell32.dll" ( ByVal src As System.IntPtr , ByVal strFileName As string , ByVal uiIconIndex As UInt32 ) As System.IntPtr


當(dāng)前名稱(chēng):vb.net與api Vbnet
本文路徑:http://weahome.cn/article/hjosed.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部