Microsoft MVP성태의 닷넷 이야기
안녕하세요.. [링크 복사], [링크+제목 복사],
조회: 11655
글쓴 사람
꼬마마법사 (huss5210 at hanmail.net)
홈페이지
첨부 파일
 

int __cdecl main(int /*argc*/, char ** /*argv[]*/)
{

    HRESULT hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    if (FAILED(hr))
        {
        printf(_T("CoInitializeEx failed!!!\n"));
        return 0;
        }
        {
        GWTest gwTest ;

        if (gwTest.Initialize())
            {
            
             gwTest.Execute();
            }

        gwTest.Terminate();
        }

    ::CoUninitialize();

    return 0;
}
void GWTest::Execute()
{
    USES_CONVERSION;

    if ( !GetPoolNames() )
        return ;

    for ( ULONG i = 0 ; i < m_culSessions ; i++ )
        {
        m_sprghSessions[i] = (HANDLE)_beginthread(HandleSession, 0, (LPVOID)OLE2A(m_sprgbstr[i]));
        if (NULL == m_sprghSessions[i])
            {
            ::SetEvent(m_hEvtStopSvc);
            break ;
            }
        }

    if ( WAIT_TIMEOUT == ::WaitForMultipleObjects( m_culSessions , m_sprghSessions, TRUE , INFINITE ) )
        {
        DisplayMsg(_T("Some session threads are still running!!\n")) ;
        }
}
bool GWTest::GetPoolNames()
{
    HRESULT    hr = S_OK;
    bool rc = true;
    int cDevices = 1;
    long lCount;
    int Index = 0;
    CComPtr<IWSConfiguredDevices>    spicd;
    VARIANT var;

    ::VariantInit(&var) ;

    printf("GetPoolNames함수 호출.\n");
    hr = spicd.CoCreateInstance(CLSID_WSConfiguredDevices);
    printf("hr의 반환값 %d\n",hr);

    if (FAILED(hr))
    {
        char buf [256];
        sprintf (buf, "CoCreateInstance of IWSConfiguredDevices failed: 0x%x\n", hr);
        DisplayMsg(_T(buf)) ;
        return false ;
    }
    
    spicd->Register((BSTR)"saprt");
        
    hr = spicd->get_Count(&lCount);

    if (FAILED(hr))
    {
        char buf [256];
        sprintf (buf, "IWSConfiguredDevices::get_Count failed: 0x%x\n", hr);
        DisplayMsg(_T(buf)) ;
        return false ;
    }


    //if (lCount > 35)
     //lCount = 35;
     printf("lCount의 반환값 %d\n",lCount);

    m_sprgbstr = new CComBSTR[lCount] ;
    m_sprghSessions = new HANDLE[lCount] ;

    for (int i = 0; i < lCount; i++)
    
        m_sprghSessions [i] = NULL;
        printf("%d\n",&hr);

     for (cDevices = 1; (cDevices <= lCount) && SUCCEEDED(hr); cDevices++)
     {
        hr = spicd->get_Item(cDevices , &var);
            
        if (SUCCEEDED(hr))
        {
            CComQIPtr<IWSDevice> spiWSDevice = var.punkVal;
            if (spiWSDevice == NULL)
                break;

            WSDeviceType wsDevType;
        
            hr = spiWSDevice->get_DeviceType(&wsDevType);
            if (FAILED(hr))
                break ;

            if ((wsDevType == DT_DIR) || (wsDevType == DT_CRT))
            {
                CComBSTR bstr ;
                hr = spiWSDevice->get_Poolname(&bstr);
                if (FAILED(hr))
                    break ;
                m_sprgbstr[Index++] = bstr ;
            }
        }
        printf("%d\n",&hr);
    }
    m_culSessions = (ULONG)Index;
    ::VariantClear( &var ) ;

    if (FAILED(hr))
        rc = false ;

    return rc;
}
실행 코드 상에 왜 lCount =0이 나오고..왜 구동이 안되는 건지 알수 있을까요?









[최초 등록일: ]
[최종 수정일: 12/10/2005]


비밀번호

댓글 작성자
 



2005-12-11 11시47분
죄송하지만, ^^ 이런 류의 질문은 답변 드릴 수 없습니다. "IWSConfiguredDevices" 인터페이스는 처음 보는 지라 혹시나 제가 모르는 어떤 유용한 인터페이스인가 싶어서 검색해 봐도 안 나오는 것을 보니, 해당 회사에서만 사용되는 인터페이스 같은데요. 이런 것은, 해당 COM 개체를 만든 업체에 직접 문의하시는 것이 빠를 것입니다.
kevin25

... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
1258최세정4/28/201420647안녕하세요~php module 오류로 고민하다가 여기까지 왔네요..ㅜㅜ [2]
1252popo4/21/201420010바인딩 질문입니다. [2]
1251(non...4/20/201424168(글쓴이의 요청으로 삭제합니다.) [11]
1249홍용규4/17/201424380app.config 파일 관련 질문 있습니다. [2]
1246(non...3/30/201420150(글쓴이의 요청으로 삭제합니다.) [1]
1245POPO3/26/201419518Http 프로토콜 관련 질문 입니다. [1]
1244(non...3/26/201419176(글쓴이의 요청으로 삭제합니다.) [1]
1241(non...3/22/201422538(글쓴이의 요청으로 삭제합니다.) [4]
1240이석주3/21/201425433인터넷 익스플로러가 hang이 걸리는 현상 문의 [1]파일 다운로드1
1238(non...3/13/201419572(글쓴이의 요청으로 삭제합니다.) [2]
1237(non...3/11/201419455(글쓴이의 요청으로 삭제합니다.) [2]
1236(non...3/11/201420350(글쓴이의 요청으로 삭제합니다.) [2]
1235(non...3/10/201418836(글쓴이의 요청으로 삭제합니다.) [2]
1234(non...3/10/201423454(글쓴이의 요청으로 삭제합니다.) [3]
1233(non...3/9/201421177(글쓴이의 요청으로 삭제합니다.) [4]
1232(non...3/8/201419888(글쓴이의 요청으로 삭제합니다.) [2]
1231(non...3/7/201420817(글쓴이의 요청으로 삭제합니다.) [9]
1230POCO3/7/201421231쓰레드 안에서 DependencyProperty get, set시 또 다른 스레드 오류.. [1]
1229(non...3/6/201422481(글쓴이의 요청으로 삭제합니다.) [11]
1228POCO3/6/201420083안녕하세요. 질문이 있습니다. [1]
1226김형진3/4/201430326안녕하세요 windows azure에 관해 질문했던 사람입니다. [2]
1224(non...3/3/201426074(글쓴이의 요청으로 삭제합니다.) [11]
1223sadf...3/3/201420126아래 질문에 답변 감사드립니다. 한가지 더 궁금한점이 있어 질문드립니다. [1]
1222(non...3/2/201420195(글쓴이의 요청으로 삭제합니다.) [4]
1221(non...3/1/201420884(글쓴이의 요청으로 삭제합니다.) [2]
1220Until2/28/201419364질문드립니다. [1]
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...