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

1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
5887HAN4/12/202311125안녕하세요 파이썬도 공유 가능 할까요? [1]
5886guest4/11/202312269필요한 어셈블리만 다운로드 및 재로딩하는 방법에 관하여 [2]
5885guest4/11/202311437c#으로 드림위버같은 거 만들어볼려는데요 [6]
5884궁금이4/11/202311398부모 클래스에서 예외 발생시 힙 영역에 할당 ? [2]
5883코딩초짜4/9/20231127510c언어 usleep 에 대해서 요 [2]
5882조은현4/7/202310566선생님 안녕하세요! wpf의 성능 개선에 대해서 질문드려요! [1]파일 다운로드1
5881guest4/6/202311505static method - <에러메시지 Extension method must be defined in a non-generic static class> [4]
5880유비4/4/202310828WPF DataGrid CollectionView, IEditableCollectionView 관련 문의 [1]
5879guest4/4/202311926Async method의 에러 표시 [3]
5878guest4/3/202312248C#으로 CMOS 설정 변경가능한지요? [4]
5875guest4/2/202312717성태님 책을 완독 하고 Static [7]
5874민성4/1/202311758안녕하세요 질문 하나만 드릴깨요~ [1]
5873guest3/31/202312187제어판에서 삭제불가 MS Edge ---> 레지스트리 편집기에서도 안보임 [6]파일 다운로드1
58723/31/202311569web config 파일 확인부탁드려요 [6]
58713/31/202311471web config 파일 수정이요 [2]파일 다운로드1
5870guest3/30/202311519.NET Core SDK 삭제 시 주의 사항 [4]파일 다운로드1
5869guest3/30/202311976Dictionary의 Update 그리고 Foreach [7]
5868guest3/29/202311312Speech Recognition과 Form1 그리고 정확도 [4]파일 다운로드1
5866월급쟁이3/28/202311030cmake 크로스 컴파일 관련하여 질문이 있습니다 [1]
5865guest3/28/202310698Github Copilot과 코딩실력 향상? [1]
5864guest3/27/202311770System.NullReferenceException - 개체참조가 개체의 인스턴스... [6]파일 다운로드1
5863guest3/24/202311289이벤트 핸들러 사라짐 현상 - Button [4]
5862guest3/21/202311655세계최초 hts와 싱글스레드 [8]
5861다크파이썬3/21/202312480WPF를 사용하려고 하려고 도서 문의합니다. [2]
5860guest3/21/202310912인텔코어 i5 CPU와 스레드 [4]
5859guest3/21/202310404개발 일지 어떻게 관리하시나요? 이런 프로그램 없나요? [3]
1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...