in Education by
I wrote a C# function of DLL that returns a byte pointer that points to an array of pointers that point to structures. My C# code as below: unsafe public void myCSharpFunc(uint ipaddress, string starttime, string finishtime, ref byte data, ref int count) { byte* bytePointer = stackalloc byte[iCount]; // get data for (int i = 0; i < iCount; i++) { sElementName = utf8Encoding.GetString(results[i].Column.Name); bElementValue = results[i].Column.Value; size = (bElementValue.Length); elmtPointer = Marshal.AllocHGlobal(size); try { // copy array to pointer Marshal.Copy(bElementValue, 0, elmtPointer, size); bytePointer[i] = (byte)elmtPointer; }catch(Exception ex){ Console.WriteLine(("kvs_getTotal() Exception 1 message: " + ex.Message + "; string: " + ex.ToString() + "; source: " + ex.Source)); } } data = bytePointer[0]; count = iCount; } data is a byte pointer that points to an array of pointers. Each pointer of the array points to a structure. In C++ DLL, I have the following function: void myCPlusFunc(DWORD ipaddress, BYTE* starttime, BYTE* endtime, BYTE* data, int* count) { byte bData; long iCount = 0L; //Initialize COM. HRESULT hr = CoInitialize(NULL); CString sStTime((char*)starttime); CString sFnTime((char*)endtime); IDrvMgr* pDrvMgr = NULL; hr = CoCreateInstance(__uuidof(CKvsDrvMgr_Total),NULL,CLSCTX_INPROC_SERVER,__uuidof(IDrvMgr),(void**)&pDrvMgr); pDrvMgr->myCSharpFunc(ipaddress, (LPCWSTR)sStTime, (LPCWSTR)sFnTime, &bData, &iCount); *count = (int)iCount; *data = bData; // 結果の処理 wchar_t strBuf[30]; wsprintf(strBuf,(LPCWSTR)L"*record count =%d",*count); MessageBox(NULL, (LPCWSTR)strBuf ,(LPCWSTR)L"◇kvs_getTotal() C++ 結果" , MB_OK); // Uninitialize COM. CoUninitialize(); return; } Then, in C test program like below: define DATETIME_LEN 14 define TEST_SIZE 5 typedef struct{ DWORD ip; char datetime[DATETIME_LEN+1]; int num; } T_TOTAL; int main(int argc, char* argv[]) { T_TOTAL tttest[TEST_SIZE] ={ {21539008, "20110712120101", 100}, {21539008, "20110712120102", 200}, {21539008, "20110712120103", 300}, {21539008, "20110712120104", 400}, {21539008, "20110712120105", 500} }; int iCount; BYTE bData; // insert data insDataFunc(tttest[0].ip, (BYTE*)tttest[0].datetime, (BYTE*)(&tttest[0]), sizeof(tttest[0])); insDataFunc(tttest[1].ip, (BYTE*)tttest[1].datetime, (BYTE*)(&tttest[1]), sizeof(tttest[1])); insDataFunc(tttest[2].ip, (BYTE*)tttest[2].datetime, (BYTE*)(&tttest[2]), sizeof(tttest[2])); insDataFunc(tttest[3].ip, (BYTE*)tttest[3].datetime, (BYTE*)(&tttest[3]), sizeof(tttest[3])); insDataFunc(tttest[4].ip, (BYTE*)tttest[4].datetime, (BYTE*)(&tttest[4]), sizeof(tttest[4])); // search data myCPlusFunc(tttest[0].ip, (BYTE*)tttest[0].datetime, (BYTE*)tttest[TEST_SIZE-1].datetime, &bData , &iCount); return 0; } After calling the search function (myCPlusFunc() function), I want to check the data returned. Would you please tell me the way to manipulate the byte pointer (&bData) that points to array of pointers that point to structures. I haven't known the way to access the array of pointers that point to structures yet. Any help is highly appreciated! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I acess like below: BYTE* p = &bData; BYTE* p1 = p; BYTE* p2 = (BYTE*)p++; BYTE* p3 = (BYTE*)p++; T_TOTAL* t1 = (T_TOTAL*)p1; T_TOTAL* t2 = (T_TOTAL*)p2; T_TOTAL* t3 = (T_TOTAL*)p3; but the data of structure t1, t2, t3 is not the same with data used for inserting. Do you have any comment why ?

Related questions

0 votes
    What is the difference between pointer to an array and array of pointers?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    In a _______ clustering index, the index record contains the search-key value and a pointer to the first ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I have Conversation classes with a members relation attribute pointing to User class. This members attribute consists ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    What are the advantages of using an array of pointers to string instead of an array of strings?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    What is an array of pointers?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    Can a pointer access the array?...
asked Jan 18, 2021 in Technology by JackTerrance
+1 vote
    Can a pointer access the array in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    2. A………… is a Panda data structure that represents a 2 D array like object (1 Point) Series DataFrame dictionary Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Point out the wrong statement. (a) Each universal function takes array inputs and produces array outputs (b) Broadcasting ... input arguments are ndarrays (d) All of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    ___________ is the collection of memory structures and Oracle background processes that operates against an Oracle ... Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    An ____________ consists of a search-key value and pointers to one or more records with that value as ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The ___ algorithm scans each index for pointers to tuples that satisfy an individual condition. (a) A2 (b ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    If access paths are available on all the conditions of a disjunctive selection, each index is scanned ... Operation in division Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Is that possible to add pointers to each other?...
asked Jan 21, 2021 in Technology by JackTerrance
+1 vote
    Is that possible to add pointers to each other?...
asked Nov 8, 2020 in Technology by JackTerrance
...