c++ - embed resource to native exe from c# -
i want embed resource in exe file using c#.
if use c++ code works :
updateresource(hresource,rt_rcdata,makeintresource(104), makelangid(lang_neutral, sublang_default),(lpvoid)text,filesize); c# code use :
 intptr handle = beginupdateresource(this.nomefilecryptato, false);  intptr fileptr = toptr(encrypted);  bool res = updateresource(handle, "rt_rcdata", "104", 1040, fileptr,     convert.touint32(encrypted.length));  endupdateresource(handle, false); actualy, c# code embed resource in exe file (let's call a.exe) if embed resource c++, a.exe can read , extract, if embed c#, a.exe cannot.
any ideas?
this declaration update resource in c# :
 [dllimport("kernel32.dll", setlasterror = true)]     static extern bool updateresource(intptr hupdate, string lptype, string lpname, ushort wlanguage,   intptr lpdata, uint cbdata); lptype , lpname both strings , if use updateresource(handle, "rt_rcdata", "104", 1040, fileptr, convert.touint32(encrypted.length)); updateresource add resource correctly exe.
the problem on c++. reach resource added c# have use lpcstr without use of makeintresource macro.
lpcstr nome = "cdata"; lpcstr tipo = "104"; hlibrary = loadlibrary(this->filename); hresource = findresource(hlibrary, tipo, nome); thanks again time!
you appear passing incorrect values, , since they're not shown, assume functions (toptr, beginupdateresource, updateresource, , endupdateresource) may incorrectly defined well.
note makeintresource(104) casts integer value 104 string pointer; not create string value "104". rt_rcdata macro value other "rt_rcdata", such makeintresource(10).
so start beginning. declaration of updateresource like? found 2 contradictory examples:
the first makes hard handle integer ids; second makes hard handle strings. guess expect use intptr both type , name parameters.
once sort out, next bit understanding makeintresource macro's equivalent in c#. , requires understanding how makeintresource smuggles integers in pointers. once understand that, it's easy tell need pass here pass integers 104 or 10 updateresource.
Comments
Post a Comment