win下 golang如何调用Dll?参数转换一直是个难题啊

rt


不会c++的表示有点困难


===================================
出个简单的题吧,


dll中函数 abc(a string,b int ) (<--举个例子..)


如何go中调用?

已邀请:

cz000 - 闷声发大才

赞同来自: philosophia14

https://golang.org/cmd/cgo/
类型都有对应的

guang7night

赞同来自: philosophia14


func main() {
var finger [11]string
score := 0
finger[0] = "57494E55494D3130303230310187454F0100012001F4000000000000000017851B150058EB020DA05CE10A0EC080E10815E0ACED031960E00F0B14610CEF08102140E50F19A158190E0A615CCE111601640E0E102184E71015C19D1E1B1381B91C270A81CD144E07A1D8320D1AE200321010E21C610D10629D650C0522B01F1A09C2DC81101162F464051463245F0515C3505D0719A35453061543A85D0615A414D30510243CDD09020B61C1D11361E9591012C25688ACEDDCAC01836880C14C5488BDEEDBBB0209C1C04A8ABDACFFCDCC040AC1C04B859BBCF06583EDD00283DEF0C0C0498599BCF0616A82FE0583FEC0C0C0478488AF58606B74040C83FDA0C0C0438386804D5E82DF760D1983BC90C0C03F8374402D698337802684A899C0C0398273291173675F503D842588C0C03582401D0A74695D5249841475C0C02F291F1304726A605785232560C0C02A24170977891112342350C0C0231C0F0474891234353340C0C01C150A0273892244444530C0C01783003073893235445640C0C01583013074893235556550C0C014830140748843345683C1C10C8214748744445670C2"

finger[1] = "57494E55494D31303032303101712C520100012001F4000000000000000017851D0E80DD81060DE1187A0B14016D19071081A4810B1A41C993100881D46F071062047C0C09C250640D0622805A0A1342908E0F0A029D5B0C17229D240C1942A497081882B9260C0B82D057150D42F0553316A30D2F0610A324862415433137090C8334372312C348522611A351736813A3714B1812E38C5C2B0943942E171343B8BB2308240020130B2409150C0C840D930F001012C40184ABB9C5C3770386B9BBC9C3C274770487B9BBCAA0C2C275770387BBBBBBA025C1C274829A0486DCADBA24C1C16672829A0286EECCBA24C1C1656F82AB0286DFEBB923C1C1626C82CC0182CF1584CA9FC1C15F6883CEC0040C1584DA9FC1C1596383DEE0040C1584EC9EC1C051555D5F6771040F1784ECAEC1C04D84AE9F66041385FFC9D0C1C04985AC683010191D2D8368C0C1C044849A43311A15443B31824DC1C0408387102F2314055F473B8239C1C03B836310241C0C776254478212C1C1332883402008016D5F514BC2C2228361100702706458C3"
finger[2] = "57494E55494D313030323031016EBB5E0100012001F4000000000000000017911B1720DD88080C810DE50714A14884071B016D13060D81E4680C0EC1F5E80D0D82315B181A623D2608054241D51E08625D4F0B1262683016104270314E0F4280364317428D2F100DC2913C200AA2A1430D15A2A9370F0C02B13C101262E5AE190462E9C60C1AE2FC370A1123009A48120300AB5A166318B10D08034144090DE35C9E220BE380A034030FE2692B126321A70A839B021012C573760283DDB0C3C36983BFC00384CDBAC2C26584BBED0384CDBB1AC1C1586484BDDD0385CDBBF0C1C1586284CDEC0385CDDAE0C1C1576184CEED0386DEDBDFC0C1566084AFFD03091184EACDC0C15260838DF074050F1784CACAC0C14C5B835BF0710A1885DB9AA0C0C0434650838AF0612086D997A8C0C044859D6650358709B85780C0C044859B32002C2B3485E75660C0C044848A202F24213B85D76570C0C143829436210F0265544B833560C0C14382D9048296746B62598220C1C2505E7187D9423140C2C47386A95533C3C674836590C4"
finger[3] = "57494E55494D313030323031012970BD0100012001F4000000000000000017950E0A00B46D080900F4E5081361188A080C41DD69110FC1F0821216E21025061682419E0505E2494F0A0E42CD293D0DC2EC38190803183C091543719F0B176390A20A0A64289A0D010E22BD2E1012C26F82BC0286BDFDB7C2C15F6C82DD0287BDFDB8F0C1C1616A82DE0287DDEDB9D0C1C0585F6882EE0188EEFCB9CBC0C05884EFFF0188FFEDBAAAC0C05884DFFF01070F1785CC8A90C0C05782CD687001091386ECA899C0C05483BDD06B770A1686EC9799C0C05183ABB062760F192185B96980C0C04C848BAD6A171F86EA9788C0C047848A994226877BA86970C0C043859867202F8729987880C0C0418D876551179A7980C0C0418D755553277A8B80C0C03F8C654454367A9DC1C1398B4246546799F0C1C1362D892576368A8027C1C222896887277980C2"
finger[4] = "57494E55494D3130303230310193F88E0100012001F4000000000000000017952115A0CC7F091220D403070C2105640A11212D040A07C169D4061061D0691A09C2054D080F4205501C144225290F1A622D280711C2442B440C025D42101802C5380A13E2DDB0130EE2E8AB091262EDA2181A82F032090B62F82D0E138309A726102309230C11A3291D0A0523283C05152341BF481B0358310E17036C662110E37897190B239D210C0883A02B0B0DC3AD9C0C1A03CDD35B0BA420941418E42472070DE425941B021122253114034DB51012C26584CBDB0184CCABC2C1576284DDCC0185CCACD0C1C1586085DEDBC00485DBCDB0C0C05287DFCEECC00385FDDBB0C0C05387BEBDFEE00585FEDBB0C0C05385ACBCF06F01081084ECBBC0C05185ABACE06B010D1684DC9AC0C04E859BABC06376131C84DA98C0C04B869998AA3F25859A7870C0C0488D88767311686760C0C0438D97847248994570C0C0418D8764536CE84560C0C03F888634535E42847144C0C03E8756426420165B483E8223C0C03B866332641908705E4737C1C136852126200E0474820233C1C134278403510701758268C2C21C8516431077836560C2"
finger[5] = "57494E55494D3130303230310167A81D0100012001F4000000000000000017951E0FA075E9051360800006092089DA110B208CE91010C0A970060D60A9680D0A40B566180A60D85A14030130C9050DA1345B0813613C6E0D08C148CF070F8150DE0C084178540B17217C810E17418C150E0F01B8D8120E21BD49140F21F5D0150CA215480A10E23D4D100EA24DC3090D2271470314C2A53A130A02D84708184368AC0C172394A2141763D1AA1E0D43D92D2311E3F8960C0115026D3D1012C25C839DF075827B0309C3C14F5F616A84ED8A0382BCC2C1515D86AFDEAB0382CC16C1C1515B86AEEEBD0482BD15C1C15184F8BC676F760482DE17C1C14F85F9ACC06A74040C83FFE0C0C14D85FA97A06372040D1682EDC0C04986BD874B5970050F1982FAC0C04787BC764AD06007131D82FAC0C04688BB76689A3823839D80C0C1478CC66678601297C0C1468CD56576535497C0C1448CC655655576A8C0C2468B654456677C80C0C3428952255797E0C1C43D362D85279A60C2C52F248459AAC3C71B829DC4"
finger[6] = "57494E55494D31303032303101600D340100012001F400000000000000001793190AA10C5A06188119E90C17E138EE0D11C145D905184190EF090BA190D10607A19CD00314E230E70A0AE261550516628405101582C8041F1B02D0231017E324362C11033D3A1C0F83583C1413C368CA531B23713A100CC379430D19E3814B191263A8A53D11A3B4A2370FA3B914331583B8701909A3C046080B8401380E0117633D631012C2598888ABBBBCC3C1528AE98ABABBCCC2C04F8CDD88A9BABDD7C1C0508CDE86A9ABBDE8C1C0518CDD86A9ABCEFAC1C0538CCE779AAADFEBC1C0558BBD789ABADEE00282B2C0558BAE798ABBDEE00382B1C0548AAB8A99BCFF0182CCC0C05288BB898ABD6D760482DBC0C05288BB799AAC6C010A1316C0C052889B689BBB6D07151D23C0C051899A589899D0392782BAC0C04F878967544061655C3B8245C0C04D868965401975685C4E453FC0C04C847863391507776D60578232C0C04B848740170902746D62832350C0C149828438100701736D648223C1"
finger[7] = "57494E55494D3130303230310172F59E0100012001F4000000000000000017941D0EA0B06E060AE0C0E00A1500C5800415E0F90F0C0FC104000A18A105120B08812DDA071A41311C0B10C15D0B0912C1A91C0E10C2492C2318624C26071522552D0C07A27549080E42754F2008A2A1C40B0C22C8CA0904C2E94304096300CD15198314370C162319450F06C321C21C080339D11705A349C421086384E10F1423A5CA0F0FC3C5D30A128418DE0D150418DB0B010FE24D471012C261656D83CBB00483DD90C2C1546085CFDCB00483DE801DC1C1586085CEDCC00483DD9018C1C05586CECEED0184DDC817C1C05786ADCFEE0384DEBA1BC1C05683ACC06870770686FEC9FCC0C05384ABCE6D770B1585C99ED0C0C05184AAAE6875101C85C87BE0C0C04E849B9C5F6C1A2485A76AD0C0C04B868AACA236864356ABC0C046869ABD813F86234499C0C0438DAAEC7124343890C0C0428DDEF95444341770C0C0434E5E8BC10875421460C0C1576A82B862863655503FC1C2738987135666604CC1C275898764563790C2C3017586657735C3"
finger[8] = "57494E55494D313030323031014D90C80100012001F400000000000000001799160E8054EA0614E07883081000A103090860D4DB040F40E8730E090139DB060BE181E30D18A188290914E1A4260A10E1DC271A0FE26D9A120D82B13F2418C2C534071642D138050C02D84C1506C2E0C60411230842081703803E0B12A3D8C60D0C6415CC0A08C424CD0C0EA434D410010D6271451012C26384ACDD01070F13C3C15B85EBDED00284DFCCC2C05786DCBEEE0485DFDCF0C1C05786CCBEFF0686EFCCEDC0C05885BBBEF077091185FBCCB0C0C057849DBD6E770C1685DCBBA0C0C05584ACAD6D02131D85DAAA90C0C05284ABAD69062086FA9898C0C050859BADF01C2A86C87797C0C04C85ABBB5031877A875980C0C04A849CB947398758775880C0C0498DAB960157665770C0C0498DAA954466455770C0C14B8CA88665553479C0C14B8CB8A86762127AC0C14A88EA9A78844136828BC0C1495487A9A7C9A0543236C1C25886B9A7BB6CC4"
finger[9] = "57494E55494D3130303230310172E9720100012001F40000000000000000179C1E0C00740407070098E80B1840C495031600EC93041AC1302906106161200B16617098060BC179131515E1C12C0A0CC1D9851C0A62002367096231331D07A265461009E26840131622702F0B18A279A10507828DB9060D82CD470A10C2F03D060EC2F94908060304C10E12E3053A060FE3194306082340C909196344A706168344360B0EC381BF0C11E39047090BC3BDCA0E12E3E85211010A4209311012C26F82BB0186EEFBA9C2C1626E82DB0387DEECBAF0C1C059636D82EC0487DEFBBBC0C1C05C636C730189DEEEBCACA0C0C05E626A82FE070F87FCDAACB0C0C0595E676F010B1687DCAACBB0C0C057829F6A02131D87CAAABBA0C0C053828D620F2188F998999AC0C050827A4834894879776A90C0C04A8D89122767656990C0C0458DAA644645556BA0C0C0448DAC864453547BB0C0C0468CDCA44244456BC1C0508CAB753235346BC1C0558C9D5731143558C1C05786DD67524B42830450C2C15E6884785355453A34C3C26F8557563055C5"
finger[10] = "57494E55494D31303032303101950A4A0100012001F40000000000000000178E2412407C860E10E0AD0C0912E0B182100640D0DE2215A0E4230406A118DA201281188D0C050159520A0B21D512170621EDD31C1B01FCA20A14E2192D0519E22C2B070D8244381711226434090B42653C1509E27841171B2280A40C17C2B1A5000762ED470508C305BA051083383B0813834D3505056350BC0A054379BB0F0743854C0608A39CC1070C23ACC00D0B43AD510B0723C94E1111E3E8491E0903ECC81506E405561313040930210A241CD211082421C613010A8261421012C26B82CD0286DEEDAAC2C1586A82DD0286DEEDAA25C1C15B6A82DD0382CF1684DAADC1C156676F750382DE1784EC8DC1C04C52636F760582FF1D85E98BB0C0C04D515E6F77060F172085E88BB0C0C049505B6C010C172186FA59BAC0C0454E566503182187FC857BA0C0C0434B535D32892A99767B90C0C04383BD703D893767666B90C0C0438DA8835566667B90C0C0438D96966465668B90C0C0438C96B76535578BC1C0448CA6A78442679CC1C0488BA788932157B0C2C14C8597AD3043398317B0C2C14B86E8EE413B2D2CC3C254555E83E66044C5"

buff0, _ := hex.DecodeString(finger[0])
buff1, _ := hex.DecodeString(finger[1])
buff2, _ := hex.DecodeString(finger[2])
buff3, _ := hex.DecodeString(finger[3])
buff4, _ := hex.DecodeString(finger[4])
buff5, _ := hex.DecodeString(finger[5])
buff6, _ := hex.DecodeString(finger[6])
buff7, _ := hex.DecodeString(finger[7])
buff8, _ := hex.DecodeString(finger[8])
buff9, _ := hex.DecodeString(finger[9])
buff10, _ := hex.DecodeString(finger[10])

mod, _ := syscall.LoadLibrary("WEVI.dll")
WeviVerify, _ := syscall.GetProcAddress(mod, "WeviVerify")
begin := time.Now().Unix()

for i := 0; i < 10000; i++ {
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff1[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff2[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff3[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff4[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff5[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff6[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff7[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff8[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff9[0])), uintptr(unsafe.Pointer(&score)))
syscall.Syscall6(WeviVerify, 6, 180, 80, 80, uintptr(unsafe.Pointer(&buff0[0])), uintptr(unsafe.Pointer(&buff10[0])), uintptr(unsafe.Pointer(&score)))
}

end := time.Now().Unix()

fmt.Println("count: 100000,", (end - begin))
}

philosophia14

赞同来自:

这种东西应该像一个字典一样
类型都是很固定的

philosophia14

赞同来自:

出个简单的题吧


dll中函数 abc(a string,b int )


如何go中调用?

要回复问题请先登录注册