Click here to Skip to main content
15,913,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Placing transparent bitmaps into dialogs Pin
John R. Shaw22-Apr-06 18:37
John R. Shaw22-Apr-06 18:37 
QuestionProperty Sheet Problem Pin
si_6921-Apr-06 23:42
si_6921-Apr-06 23:42 
AnswerRe: Property Sheet Problem Pin
includeh1022-Apr-06 4:40
includeh1022-Apr-06 4:40 
GeneralRe: Property Sheet Problem Pin
si_6922-Apr-06 11:58
si_6922-Apr-06 11:58 
Questionhow can i get my app path? Pin
Sina Parastgary21-Apr-06 23:29
Sina Parastgary21-Apr-06 23:29 
AnswerRe: how can i get my app path? Pin
Naveen21-Apr-06 23:40
Naveen21-Apr-06 23:40 
AnswerRe: how can i get my app path? Pin
Michael Dunn22-Apr-06 9:14
sitebuilderMichael Dunn22-Apr-06 9:14 
QuestionUsing OLE IStream in a thread Pin
Waldermort21-Apr-06 23:27
Waldermort21-Apr-06 23:27 
So far I have had everything working without a hitch, right up until I introduced threads to my projects. Let me explain what I am doing. I create a class which opens a CompoundFile using ole2's IStorage and Istream. The class then creates another class object passing along the Istream pointer.

This new class then creates a clone of the stream and launches a thread from where the stream should be read. The cloned copy is stored as a class member, before the thread is launched the seek pointer is set and there are no problems. The thread function is a static class member and I have enabled the access to the rest of the class by passing the this pointer.

The problem is here from inside the thread
long hr = 0;
hr = stream->Read(&_id,2,&s);
if (FAILED(hr)) {
    printf("Read stream failed");
}
stream->Read(&_ssz,2,&s);
The program throws an 'Access Error' when trying to read. The address of the stream is correct, but the IUnknown members of the stream are not.

This is the code I used to initialy open the document and stream, I have a feeling the problem is here somewhere.
// Open the document as an OLE compound document.
hr = ::StgOpenStorage(wcFilename, NULL,STGM_READ|STGM_SHARE_DENY_WRITE , NULL, 0, &pStorage);
if(FAILED(hr)) {
    if(hr == STG_E_FILENOTFOUND)
        printf("File not found.");
    else if(hr == STG_E_FILEALREADYEXISTS)
        printf("Not a compound file.");
    else
        printf("StgOpenStorage() failed w/error %08lx", hr);
    return;
}
hr = pStorage->OpenStream(L"Workbook",NULL,NULL,STGM_READ|STGM_SHARE_EXCLUSIVE|STGM_DIRECT,NULL,&pStream);
if(FAILED(hr)) {
    printf("Open stream failed");
    pStorage->Release();
    return;
}

AnswerRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 0:32
Stephen Hewitt22-Apr-06 0:32 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 0:46
Waldermort22-Apr-06 0:46 
GeneralRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 1:08
Stephen Hewitt22-Apr-06 1:08 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 1:58
Waldermort22-Apr-06 1:58 
GeneralRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 2:01
Stephen Hewitt22-Apr-06 2:01 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 2:14
Waldermort22-Apr-06 2:14 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 2:41
Waldermort22-Apr-06 2:41 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 3:36
Waldermort22-Apr-06 3:36 
GeneralRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 3:51
Stephen Hewitt22-Apr-06 3:51 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 4:08
Waldermort22-Apr-06 4:08 
GeneralRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 4:26
Stephen Hewitt22-Apr-06 4:26 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 4:42
Waldermort22-Apr-06 4:42 
GeneralRe: Using OLE IStream in a thread Pin
Waldermort22-Apr-06 6:23
Waldermort22-Apr-06 6:23 
GeneralRe: Using OLE IStream in a thread Pin
Stephen Hewitt22-Apr-06 1:19
Stephen Hewitt22-Apr-06 1:19 
QuestionWhy can't debug in multy top document program(vs2003)? Pin
zhoucheng21-Apr-06 23:13
zhoucheng21-Apr-06 23:13 
QuestionSuggestions for Code Obfuscator and/or Encrypter Pin
JSadleir21-Apr-06 22:18
JSadleir21-Apr-06 22:18 
AnswerRe: Suggestions for Code Obfuscator and/or Encrypter Pin
Nick_Kisialiou22-Apr-06 0:53
Nick_Kisialiou22-Apr-06 0:53 

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.