Dunno do not do do this about this? 아래 구조의 내용은 다른 곳에서 정의됩니다. 코드를 실행하면 4 개의 0을 출력합니다. 어떤 도움을 크게 주시면 감사하겠습니다 .....C# windows 폼 응용 프로그램의 목록 상자에 구조체의 내용을 표시하는 방법
public class NativeMethods
{
public struct FT_DEVICE_LIST_INFO_NODE
{
public uint ID;
public uint LocId;
public string SerialNumber;
public string Description;
}
[DllImportAttribute(@"C:\Users\Brendan\Documents\libMPSSE.dll", EntryPoint = "SPI_GetNumChannels")]
public static extern uint SPI_GetChannelInfo(uint index, ref FT_DEVICE_LIST_INFO_NODE chanInfo);
}
public partial class Form1 : Form
{
List<uint> items = new List<uint>();
public Form1()
{
InitializeComponent();
NativeMethods.FT_DEVICE_LIST_INFO_NODE devlist = new NativeMethods.FT_DEVICE_LIST_INFO_NODE();
for(uint x=0;x<4;x++)
{
index = 0;
items.Add(NativeMethods.SPI_GetChannelInfo(index, ref devlist));
}
listBox.DataSource = items;
}
}
extern 함수 SPI_GetChannelInfo에 DllImport 속성이 있습니까? extern 코드를 디버깅하려고 했습니까 (가능한 경우)? –
예 C DLL을 가져옵니다, 나는 그것이 작동하는 것을 알고 있습니다 다른 텍스트 상자에 내용을 출력했습니다. 내가 목록 상자에 모든 매개 변수를 출력하는 것,하지만 어쩌면 이것이 서로 다른 유형의 매개 변수를 uint와 문자열이기 때문에 어떨까요? – john
좀 더 간단하게하기 위해 DLLimport 속성을 생략했습니다. – john