推 horngsh:我在C#裡用win32 api用得很順, 端看用者對P/Invoke熟不熟 02/24 15:28
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