{"id":2538,"date":"2009-03-05T10:25:32","date_gmt":"2009-03-05T07:25:32","guid":{"rendered":"http:\/\/studentpmr.ru\/?p=2538"},"modified":"2009-03-05T10:25:32","modified_gmt":"2009-03-05T07:25:32","slug":"%d1%8d%d0%ba%d1%81%d0%bf%d0%be%d1%80%d1%82-%d0%b8-%d0%b8%d0%bc%d0%bf%d0%be%d1%80%d1%82-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b9-%d0%b8%d0%b7-dll","status":"publish","type":"post","link":"https:\/\/studentpmr.ru\/?p=2538","title":{"rendered":"\u042d\u043a\u0441\u043f\u043e\u0440\u0442 \u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437 DLL"},"content":{"rendered":"<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 DLL \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430: | \u0430\u0434\u0440. | hint | \u0438\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b |, \u0442.\u0435. \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0433\u0434\u0435:<br \/>\n\u0430\u0434\u0440. \u2013 \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0435\u043c + \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 DLL \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0438 DLL.<!--more--><br \/>\nhint \u2013 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<br \/>\n\u0438\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u2013 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430<br \/>\n\u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00bb<br \/>\n__stdcall__declspec(__dllimport)int Func(\u2026);<br \/>\nextern \u201cC\u201d<br \/>\n__import<br \/>\n\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 LIB \u2013\u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0415\u0433\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. \u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 DLL \u043d\u0430\u0434\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00bb, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c __import  \u0438\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e extern \u201cC\u201d. \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c DLL, \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 LoadLibrary, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c:<br \/>\n&#8212;\t\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0432 DLL.<br \/>\n&#8212;\t\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<br \/>\nFARPROC GetProcAddress(<br \/>\nHINSTANCE hDLL,<br \/>\nLPCSTR ProcName);<br \/>\n\u0438\u043b\u0438<br \/>\nFARPROC GetProcAddress(<br \/>\nHINSTANCE hDLL,<br \/>\nint Number);<\/p>\n<p>xx=GetProcAdress(hDll, MAKEINTRESOURCE(r)); \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f<br \/>\nxx(Param 1, Param 2);<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f DLL:<br \/>\n\/\/ MyDll.cpp<br \/>\ndouble dblValue(double);<br \/>\ndouble halfValue(double);<br \/>\nextern \u201cC\u201d_declspec(__dllexport)double<br \/>\nChangeValue(double,bool);<br \/>\ndouble dblValue(double, Value){return Value*Value}<br \/>\ndouble halfValue(double, Value){return Value*12.0}<br \/>\ndouble ChangeValue(double Value, bool opt) {return opt ? dblValue(Value): halfValue(Value);}}<\/p>\n<p>\/\/MyDll.h<br \/>\n#ifdef __BUILD_THE_DLL<br \/>\n#define __EXPORT_TYPE  __export<br \/>\n#else<br \/>\n#define __EXPORT_TYPE __import<br \/>\n#endif<br \/>\ndouble EXPORTTYPE  ChangeValue(double,bool);<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u0447\u0430\u043c\u0438:<br \/>\n\/\/heapEx.h<br \/>\nclass HeapExample<br \/>\n{ static Hheap heap;<br \/>\nstatic UINT num_alloc_in_heap; \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u043a\u0443\u0447\u0438<br \/>\n\u2026\u2026.<br \/>\npublic:<br \/>\nvoid* operator new (size_t size);<br \/>\nvoid* operator delete(void* p);<br \/>\n\u2026\u2026.<br \/>\n};<\/p>\n<p>\/\/heapEx.cpp<br \/>\nHheap  HeapExample::heap = NULL;<br \/>\nUINT   HeapExample::num_alloc_in_heap =0;<\/p>\n<p>void* HeapExample::operator new(size_t size)<br \/>\n{<br \/>\nif (heap)<br \/>\n{<br \/>\nheap = HeapCreate (HEAP_NO_SERIALIZE,0,0);<br \/>\nif (!heap) return NULL;<br \/>\n}<br \/>\nvoid p*;<br \/>\nwhile(!(p=(void*)HeapAlloc(heap,o,size))<br \/>\n{<br \/>\nif(_new_handler)(*_newhandler)();<br \/>\nelse break;<br \/>\n}<br \/>\nif (p)<br \/>\nnum_alloc_in_heap++;<br \/>\nreturn p;<br \/>\n}<br \/>\n}<br \/>\nvoid HeapExample::operator delete(void *p)<br \/>\n{<br \/>\nif(HeapFree(heap,0,p))<br \/>\nnum_alloc_in_heap&#8212;;<br \/>\nif (!num_alloc_in_heap)<br \/>\nif(HeapDestroy(heap))<br \/>\nHeap=NULL;<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 DLL \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430: | \u0430\u0434\u0440. | hint | \u0438\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b |, \u0442.\u0435. \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0433\u0434\u0435: \u0430\u0434\u0440. \u2013 \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0435\u043c + \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 DLL \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0438 DLL.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"_links":{"self":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2538"}],"collection":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2538"}],"version-history":[{"count":1,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2538\/revisions"}],"predecessor-version":[{"id":2539,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2538\/revisions\/2539"}],"wp:attachment":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}