tag:blogger.com,1999:blog-10893214.post114963826728181180..comments2023-10-05T01:08:03.227-07:00Comments on cawood's blog - geek literature: C# Interop: unsigned char* C .libStephen Cawoodhttp://www.blogger.com/profile/07948009840630937442noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-10893214.post-59288917658122583122007-05-15T07:29:00.000-07:002007-05-15T07:29:00.000-07:00jef, yes that would be good. please let me know ho...jef, yes that would be good. please let me know how you solve it and include any helpful links.Stephen Cawoodhttps://www.blogger.com/profile/07948009840630937442noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-78043192575614524912007-05-08T12:16:00.000-07:002007-05-08T12:16:00.000-07:00Ok, I think i get it now.the wrapper dll i would m...Ok, I think i get it now.<BR/>the wrapper dll i would make would be the same as the one in my possesion<BR/>google is the answer :-)<BR/><BR/>thx for your answers and your patience. Would you like me to report back my progress?Unknownhttps://www.blogger.com/profile/06360545587610678196noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-44957876696095470542007-05-08T11:52:00.000-07:002007-05-08T11:52:00.000-07:00jef, you don't want to use the .lib -- use the .dl...jef, you don't want to use the .lib -- use the .dll. if you use the .lib you are literally adding work.<BR/><BR/>in other words, don't use a wrapper unless you have to. you would be adding an unnecessary layer to your app. even if you use the .lib, you still have to marshal the data in your code. use the .dll and figure out the marshaling.Stephen Cawoodhttps://www.blogger.com/profile/07948009840630937442noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-71791488525028775232007-05-08T02:27:00.000-07:002007-05-08T02:27:00.000-07:00Hey good news :-) I found a .lib file which probab...Hey good news :-) I found a .lib file which probably can be used in the same way as the dll file.<BR/>But since i'm really noobish in programming, i'm going to ask for some help:)<BR/><BR/>First of all:<BR/>When I call a function in the .cpp(by example: "create(id, scale, ptrImage);" in your code. i get an error saying 'create': identifier not found.<BR/>It means that the function "create" im trying to call, is not recognised. Where should i place the identifier? Or where should I tell the compiler he needs to use the function from the lib file?<BR/><BR/>Another thing is it normal the .lib file is somewhat machine language.<BR/>IC_getSpecialData@12__imp__LEGIC_<BR/>getSpecialData@12__imp__wait4Credential@8<BR/>with next to it hexadecimal numbers corresponding to the functions on the right<BR/><BR/>again TY verry muchUnknownhttps://www.blogger.com/profile/06360545587610678196noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-39763789469324770312007-05-07T13:39:00.000-07:002007-05-07T13:39:00.000-07:00yes, your question is a standard interop problem, ...yes, your question is a standard interop problem, what you want to do is marshal an unsigned char* into your program (IntPtr for C#).<BR/><BR/>take another look at the "C# Using the data" section of my post. that's how I handled the unsigned char* data type in C#. you will want to do something like that.<BR/><BR/>I found that the .Net Interop newsgroups were useful. if you're using .Net, you can go there for help.Stephen Cawoodhttps://www.blogger.com/profile/07948009840630937442noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-72375273340333527832007-05-07T13:23:00.000-07:002007-05-07T13:23:00.000-07:00ah ok :-S i had the same problem though as you had...ah ok :-S i had the same problem though as you had. Accesing an unsigned char * used by a dll (for your problem a .lib) in a C# programm. I must have misunderstood some of your english (since im not native english speaking) i thought a dll could be wrapped in a new dll and so use the unsigned char*. (I have a sdk package with a dll programmed in C from which i dont posses the source) I'll google some answers and reply here so more people having the same problem might find their solution easier.<BR/>Thx for the blog and rapid answer anyhow.<BR/>GreetsUnknownhttps://www.blogger.com/profile/06360545587610678196noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-23251507688044012212007-05-07T08:24:00.000-07:002007-05-07T08:24:00.000-07:00jef, you'll see at the top of the post that this t...jef, you'll see at the top of the post that this topic applies to accessing a function in a .lib file. if you already have a .dll, then you don't need a wrapper. try to google accessing a C .dll from the language that you're trying to use (I assume it's c# since you found my blog).<BR/><BR/>but to answer your first question... the reason that I don't mention a specific .lib, or .dll file in my post is that the post only addresses what to do if you have a .lib that you need to wrap in a .dll. therefore the .lib is the file that you have and the .dll is the file that you need to create.Stephen Cawoodhttps://www.blogger.com/profile/07948009840630937442noreply@blogger.comtag:blogger.com,1999:blog-10893214.post-67843719790988178082007-05-07T05:24:00.000-07:002007-05-07T05:24:00.000-07:00HelloI have a situation more or less like your'si ...Hello<BR/>I have a situation more or less like your's<BR/>i have a dll writen in C which defines the function : signed int anticollision (unsigned char* anticollisionData, int* lenght);<BR/><BR/>I dont get how this wrapper DLL u created, calls the function in the lib or dll file. you dont say anything about wich .lib file or .dll file to use.<BR/>I'm really a noob in programming (not totaly but compared to most users here i am).<BR/><BR/>would this be the correct way to make the cpp?<BR/>=================================<BR/>wrapper.cpp<BR/>=================================<BR/>WRAPPER_API signed int anticollision_wrapped (void** anticollisionData, void** lenght)<BR/>{<BR/> signed int retCode = -1;<BR/> unsigned char* ptranticollision = NULL;<BR/> int* ptrlenght = NULL;<BR/> if (NULL != *anticollisionData && NULL != *lenght)<BR/> {<BR/> ptranticollision = (unsigned char*)GlobalLock(*anticollisionData);<BR/> ptrlenght = (int*)GlobalLock(*lenght);<BR/> retCode = anticollision(anticollisionData, lenght);<BR/> GlobalUnlock(*anticollisionData);<BR/> GlobalUnlock(*lenght);<BR/> }<BR/> else<BR/> {<BR/> if (NULL != anticollisionData)<BR/> {<BR/> ptranticollision = (unsigned char*)GlobalLock(*anticollisionData);<BR/> retCode = anticollision(anticollisionData, lenght);<BR/> GlobalUnlock(*anticollisionData)<BR/> }<BR/> else<BR/> {<BR/> if (NULL != lenght)<BR/> {<BR/> ptrlenght = (int*)GlobalLock(*lenght);<BR/> retCode = anticollision(anticollisionData, lenght);<BR/> GlobalUnlock(*lenght);<BR/> }<BR/> else<BR/> {<BR/> retCode = anticollision(anticollisionData, lenght);<BR/> *anticollisionData = (void*)ptranticollision;<BR/> *lenght = (void*)ptrlenght;<BR/> }<BR/> }<BR/> }<BR/>return retCode;<BR/><BR/>}<BR/><BR/>============================<BR/>Any help on this subject would be appreciated thx in advanceUnknownhttps://www.blogger.com/profile/06360545587610678196noreply@blogger.com