在.net中使用api的方法
www.yescnet.com cnet中文网
可能说vb.net是一个令人恨又令爱的编程软件,新版的.net不像vb6那样多的支持api调用,好不容易在msdn中找到的使用api的方法,代码如下:
[visual basic]
setlasterror := true, charset := charset.unicode, _
exactspelling := true, _
callingconvention := callingconvention.stdcall)> _
public shared function movefile(src as string, dst as string) as boolean
leave function empty – dllimport attribute forces calls to movefile to
be forwarded to movefilew in kernel32.dll
end function
这是调用kernel中的movefile函数,在dllimport中必须声明要调用的函数库明,如kernel32,user32,gdi32等,entrypoint为要调用函数名.
下面是调用showwindow函数的实例:
setlasterror:=true, charset:=charset.unicode, _
exactspelling:=true, _
callingconvention:=callingconvention.stdcall)> _
public shared function showwindow(byval hwne as integer,_
byval ncmdshow as integer) as integer
end function
顺便说一句,在.net中使用从前vb6中hwnd属性的方法是:
me.handle.toint32
