How to import void * C API into C#?

后端 未结 3 1100
孤独总比滥情好
孤独总比滥情好 2021-02-20 10:17

Given this C API declaration how would it be imported to C#?

int _stdcall z4ctyget(CITY_REC *, void *);

I\'ve been able to get this far:

<
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-20 11:08

    As far as I can tell the C declaration of z4ctyget is:

    int z4ctyget(CITY_REC *cityrec, char *zipcode);
    

    The second parameter is a 5 character ANSI string representing the zip code at which you want to start your search or "00000" to start at the beginning of the file. So your declaration should be:

    [DllImport(@"zip4_w32.dll", CharSet = CharSet.Ansi)]
    private extern static int z4ctygetSTD(ref CITY_REC args, string zipcode);
    

提交回复
热议问题