????????棬???????OpenTK??MOgre??????????????C#???????????????????C++.??????????????????.????????????ж?????????????????????P/Invoke(DllImport)???????????OpenTK????????????????C++ -> C++/CRL -> C#????????????P/Invoke????г?C++ Interop??MOgre????????????.?????????????????????P/Invoke???????????????http://msdn.microsoft.com/zh-cn/library/2x8kf7zx.aspx .
??????????????????????ж???C++?????????????????豸????????????window????????????豸??????????????????????IOS??????д???豸??????.??????????IOS??????д??????????????????window?????£????????C#????????????????????е?DEOM.????????????????????????????C#??C++?t???ù??????????????д?????????????????????????????.???лл??????????????????????????????(OpenGL???)???????????C++??????????????????????????????????????????????????C++??????????C++???????????.
??????????????????????????VS2013????????????Щ?汾????????.
??????IOS?????μ???????vs2013?У?????????sprintf?????????????vs2013????????e???????sprintf?????汾??sprintf_s??????????????飬?????Щ??strcpy??strcpy_s??localtime??localtime_s.???????????e???汾????????????????_s????????????????????????????嶼?????.
?????????socket????Щ?????????????????IOS????LINUX??????socket?????close????vs2013????closesocket??ioctl??ioctlsocket?????????????????????????socket???????????????????????????socket?????????????????????λ???д???????????IOS??????ioctl????SIOCGIFCONF????????????ifconf???飬????ifconf???????????ioctl????SIOCGIFBRDADDR?????????????????????????????е??Щifconf?????y???????????????????????????????????????????????????е?.????window?????£???????WSAIoctl??????????SIO_GET_INTERFACE_LIST???INTERFACE_INFO????壬????????????????????????????????????????API??????.
???????????????????IOS?????μ???????VS2013?????????????????????????????????£?????????????Щ?????????????????????????壬??????Щ??????????????????????????????????API?????????????????????????????IOS?????μ??????????£???????ù??????????????????????????????????????????????.h??.cpp???????????ù??С??.h???.cpp??????????????????????????????????????????????????????????????????????????С?????????????????????????????????????????о???????.
??????????????IOS?μ?????????????????VS2013????????????????????.???′??? ???.
????std::thread detectThread(&PApi::DetectProc?? this);
????detectThread.detach();
???????IOS??????????????????STL?μ??????????????£????????????а???????STL??????????????????????????????????detach??????????????????????????????????????????????????????????????????.??????????????????????????????????????????????????о?????????????????window api??????????.???????????????£????????????DetectProc????????????.
????DWORD threadId = 0;
????HANDLE threadHandle = CreateThread(0?? 0?? DetectProc?? this?? 0?? &threadId);
????CloseHandle(threadHandle);
????threadHandle = INVALID_HANDLE_VALUE;
???????????С??????????????????????????C#??.????????????????????P/Invoke?????????????????????.
??????????C++???????????????????????й?C++DLL?????????C#?й?DLL??????????д??Public?????????DLL???????????????й?C++????????????????????????API????????????__declspec(dllexport).???????????P/Invoke???????P/Invoke???÷??й?C++???API??????????API??????__declspec(dllexport).
?????????????P/Invoke??????????????????÷?????????????????????C#?????DLLImport?????????й??????ù????__declspec(dllexport)??????API.????????????????????й?C++????????C++/CRL???й?C++????й?C++???????.h????.cpp????????????????????Щ???????????????о???????C#??????й?C++?????????????????C#????DLL????????????й????????????????????й?C++???????й?C++??????????????????????API?????????DLLImport????????????????鷳Щ??????????????????Щ????ЩC++??????????C#????У???memcyp???Щ?????????????C++???????.
????__declspec(dllexport)??????????????DLL????API???????????????P/Invoke??????Щ??????API????????????????????????__declspec(dllimport)???????????????????????????????DLL?е???????????????????????????????????????????.????????γ???????.
1 #ifdef TRADITIONALDLL_EXPORTS
2    #define TRADITIONALDLL_API __declspec(dllexport)
3 #else
4    #define TRADITIONALDLL_API __declspec(dllimport)
5 #endif
6
7 extern "C" {
8    TRADITIONALDLL_API double GetDistance(Location?? Location);
9    TRADITIONALDLL_API void InitLocation(Location*);
10 }