COM objects in windows XP...

I don't know...I downloaded Visual Studio 2010 and 2008 on my Windows XP, but when I compiled a code, it worked but I cannot CoCreateInstence();

I guess it's because of my OS?!?

Code-this is the MSDN version(edited) to verify my problem:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <windows.h>
#include <shobjidl.h> 

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | 
        COINIT_DISABLE_OLE1DDE);
    if (SUCCEEDED(hr))
    {
        IFileOpenDialog *pFileOpen;

        // Create the FileOpenDialog object.
        hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL, 
                IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));

        if (SUCCEEDED(hr))
        {
            // Show the Open dialog box.
            hr = pFileOpen->Show(NULL);

            // Get the file name from the dialog box.
            if (SUCCEEDED(hr))
            {
                IShellItem *pItem;
                hr = pFileOpen->GetResult(&pItem);
                if (SUCCEEDED(hr))
                {
                    PWSTR pszFilePath;
                    hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);

                    // Display the file name to the user.
                    if (SUCCEEDED(hr))
                    {
                        MessageBox(NULL, pszFilePath, L"File Path", MB_OK);
                        CoTaskMemFree(pszFilePath);
                    }
                    pItem->Release();
                }
				else MessageBox(NULL, L"Error1", L"File Path", MB_OK);
            }
			MessageBox(NULL, L"Error2", L"File Path", MB_OK);
            pFileOpen->Release();
        }
		MessageBox(NULL, L"Error3", L"File Path", MB_OK);
        CoUninitialize();
    }
    return 0;
}
What error is CoCreateInstance returning? Is it REGDB_E_CLASSNOTREG = 0x80040154 ?

But yes, IFileDialog, IFileOpenDialog, ... are marked in MSDN as Windows Vista and newer.

Andy

PS I've also tried your code on my (Windows XP SP3) computer and got error REGDB_E_CLASSNOTREG.

PPS And I've just checked my PC's registry: no sign of a CLSID {DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7} (i.e. FileOpenDialog).
Last edited on
Mann damn!!! I hate Vista(very much) and win 7(a little) but I think I must upgrade from Win XP SP3 to Win 7.
Or you could wait for Windows 8 ??? :-/
Topic archived. No new replies allowed.