Microsoft MVP성태의 닷넷 이야기
안녕하세요.. [링크 복사], [링크+제목 복사],
조회: 11044
글쓴 사람
꼬마마법사 (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

... 61  62  63  64  [65]  66  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
981김창욱7/11/201121159주식형태의 프로그램 처럼 SQL서버의 특정 필드 데이터의 변화가 있을때 재 클라이언트가 정보를 갱신 할 수 있게 하는 방법은 없을까요? [2]
980YJ7/7/201120877App Pool idle time 과 WCF 서비스의 비동기 function 호출. [3]
979왕초보7/1/201119200Apache + IIS Redirect [2]
9776/16/201123098웹컨트롤 어느거 쓰는게 좋나요 [1]
976박성준6/13/201118581VS2008 Add-in 구현 관련 질문 [4]
972김길6/6/201120872메모리 해제 예외 처리 관련.. [2]
971강동원5/29/201118449firebird install건 [1]
970임동찬5/18/201119218ASP.net 솔루션 디버깅 관련 [1]
969이성환5/4/201120831WMI 를 사용하지 않고 하드웨어 정보를 가져올 수 없을까요? [3]
968김동미4/28/201120268안녕하세요 다시 한번 문의를 드립니다.. [2]파일 다운로드1
967임동찬4/22/201122943C# using문 관련 [9]
964김동미4/18/201120596wcf IsOneWay 속성관련 문의 입니다..
965정성태4/18/201121930    답변글 [답변]: wcf IsOneWay 속성관련 문의 입니다..
966김동미4/19/201119565        답변글 [답변]: [답변]: wcf IsOneWay 속성관련 문의 입니다.. [1]
963최재훈4/12/201118198wcf inactivityTimeout 설정시 문의 사항이 있습니다. [2]
962임동찬4/8/201117843TFS 사용관련 [1]
961임동찬4/7/201118100XSD & XML & XmlCodeGenerator [2]
960임동찬4/5/201119774XML Schema Editor [4]
959immm3/24/201117553로그인 연동 어려운 건가요? [1]
958꼭지3/3/201119708Supporting compressed request in WCF 3.5 [5]
957임동찬2/21/201120130WCF channel faulted 관련 [2]
956윤용한2/18/201123560WaitHandle.WaitOne 과 Stopwatch에 관한 질문 [3]
955최광욱2/17/201120235TFS 에서 소스 영구 제거 방법 [1]
954한장우2/16/201117899atl activeX 질문이요~ [1]
952박용운2/16/201118770IE8.0에서 BHO [1]
953박용운2/16/201118727    답변글 [답변]: IE8.0에서 BHO
... 61  62  63  64  [65]  66  67  68  69  70  71  72  73  74  75  ...