Click here to Skip to main content
15,880,405 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: TreelistView c++/cli Pin
Gerry Schmitz23-Aug-23 5:49
mveGerry Schmitz23-Aug-23 5:49 
AnswerRe: TreelistView c++/cli Pin
Temblor23-Sep-23 3:54
Temblor23-Sep-23 3:54 
QuestionHeap Corruption in richedit Pin
ForNow15-Jan-23 12:49
ForNow15-Jan-23 12:49 
AnswerRe: Heap Corruption in richedit Pin
Victor Nijegorodov15-Jan-23 20:26
Victor Nijegorodov15-Jan-23 20:26 
GeneralRe: Heap Corruption in richedit Pin
ForNow16-Jan-23 0:10
ForNow16-Jan-23 0:10 
Questiontrying to understand DLL and Thread local storage Pin
ForNow4-Dec-22 8:52
ForNow4-Dec-22 8:52 
AnswerRe: trying to understand DLL and Thread local storage Pin
Richard Deeming4-Dec-22 21:42
mveRichard Deeming4-Dec-22 21:42 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 2:40
ForNow5-Dec-22 2:40 
I am refering to the following example i found in the codeproject my lack of understanding is due to the fact that gw_dwThreadIndexis defined in global storage not stack/local storage

C++
Shrink ▲   
struct ThreadData {
    // some thread specific data
};
...
DWORD g_dwThreadIndex;

extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, 
                      DWORD dwReason, LPVOID /*pReserved*/)
{
    ThreadData* pData;

    switch (dwReason) {
        case DLL_PROCESS_ATTACH:

            // allocate a TLS index

            g_dwThreadIndex = ::TlsAlloc();
            if (g_dwThreadIndex == TLS_OUT_OF_INDEXES)
                return FALSE;

            //break;        // execute the DLL_THREAD_ATTACH code

        case DLL_THREAD_ATTACH:

            // allocate memory for this thread

            pData = (ThreadData*) ::LocalAlloc(LPTR, sizeof(ThreadData));
            if (pData == 0)
                return FALSE;

            ::TlsSetValue(g_dwThreadIndex, (LPVOID) pData);
            break;

        case DLL_THREAD_DETACH:

            // release memory for this thread

            pData = (ThreadData*) ::TlsGetValue(g_dwThreadIndex);
            if (pData != 0)
                ::LocalFree((HLOCAL) pData);
            break;

        case DLL_PROCESS_DETACH:

            // release memory for this thread

            pData = (ThreadData*) ::TlsGetValue(g_dwThreadIndex);
            if (pData != 0)
                ::LocalFree((HLOCAL) pData);

            // release the TLS index

            ::TlsFree(g_dwThreadIndex);
            break;
    }

    return TRUE;
}

    ...
};

GeneralRe: trying to understand DLL and Thread local storage Pin
Richard Deeming5-Dec-22 4:29
mveRichard Deeming5-Dec-22 4:29 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 4:41
ForNow5-Dec-22 4:41 
GeneralRe: trying to understand DLL and Thread local storage Pin
Richard Deeming5-Dec-22 6:01
mveRichard Deeming5-Dec-22 6:01 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 7:39
ForNow5-Dec-22 7:39 
AnswerRe: trying to understand DLL and Thread local storage Pin
Richard MacCutchan5-Dec-22 5:56
mveRichard MacCutchan5-Dec-22 5:56 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 7:33
ForNow5-Dec-22 7:33 
GeneralRe: trying to understand DLL and Thread local storage Pin
Richard MacCutchan5-Dec-22 7:54
mveRichard MacCutchan5-Dec-22 7:54 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 8:00
ForNow5-Dec-22 8:00 
AnswerRe: trying to understand DLL and Thread local storage Pin
jschell5-Dec-22 6:06
jschell5-Dec-22 6:06 
GeneralRe: trying to understand DLL and Thread local storage Pin
ForNow5-Dec-22 7:37
ForNow5-Dec-22 7:37 
GeneralRe: trying to understand DLL and Thread local storage Pin
jschell12-Dec-22 10:21
jschell12-Dec-22 10:21 
NewsGood news, /clr builds will soon add C++ 20 support! Pin
John Schroedl15-Nov-22 5:49
professionalJohn Schroedl15-Nov-22 5:49 
Questionrekursif Pin
Achmad Roihan28-Oct-22 2:31
Achmad Roihan28-Oct-22 2:31 
AnswerRe: rekursif Pin
OriginalGriff28-Oct-22 2:38
mveOriginalGriff28-Oct-22 2:38 
Questionrekursif program (Recursive Program) Pin
Achmad Roihan26-Oct-22 19:51
Achmad Roihan26-Oct-22 19:51 
AnswerRe: rekursif program (Recursive Program) Pin
OriginalGriff26-Oct-22 20:02
mveOriginalGriff26-Oct-22 20:02 
QuestionHow to close & clear the oledbconnection on form2()_load? Pin
Paramu19739-Oct-22 14:10
Paramu19739-Oct-22 14:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.