Re: [問題] C# call win32 API
sample code (using managed code)
===========================================
import System.Runtime.InteropServices;
...
public static extern ulong abc
(string Disk, ulong Session, IntPtr List,out ulong size);
...
//Call abc
ulong s = 32;
String disk = "A";
ulong r = 0;
ulong Session = 1;
try{
IntPtr ptr = Marshal.AllocHGlobal(s);
r = abc(disk,Session,ptr,s);
}
catch(Exception ex){
...
}
finally{
if (ptr !=IntPtr.Zero){
Marshal.FreeHGlobal(ptr);
}
}
ps.在C#裡面,最好少用unmanaged code...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.64.95
推
02/24 15:28, , 1F
02/24 15:28, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):