Microsoft MVP성태의 닷넷 이야기
안녕하세요.. [링크 복사], [링크+제목 복사],
조회: 12492
글쓴 사람
꼬마마법사 (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)
862장근배1/28/201019652AppPolId를 알 수 있는 방법이 있는지요? [1]
864장근배2/1/201019208    답변글 [답변]: AppPolId를 알 수 있는 방법이 있는지요?
858생초보1/26/201019587안녕하세요.. 파일 생성 처리 문제로 .... [2]
857꼭지1/22/201026385How to support Basic + Windows authentication mode in WCF(RESTful service) [4]파일 다운로드2
856질의자1/13/201023273vcredist_x86 배포 관련 여쭙습니다. [1]
855임동찬1/13/201022141이벤트 핸들러와 쓰레드의 관계 2 [4]파일 다운로드2
854임동찬1/12/201022341이벤트 핸들러와 쓰레드의 관계 [1]
853장근배1/12/201020901압축 프로그램,, [1]
852임동찬1/6/201018236base.OnStart(agrs) [1]
851한귀순1/6/201023607oracle & transaction 질문 [5]
850박한주12/31/200920834COM과 C#간 권한 문제에 관해 여쭤봅니다. [5]
848날쌘돌이12/22/200921859C#으로 개발하는 ActiveX 디버깅 문제 [5]
847최승문12/16/200920618winform에서 웹서비스를 이용할때, 객체가 전송안되는 문제... [2]
846이강구12/14/200919513ATL COM 제작 문의 [3]
845김재영12/9/200922337ClickOnce에서 WinForm을 배포시 변동되는 Args값을 넘길 수 있나요? [3]파일 다운로드1
843김재영12/2/200919918Hyper-V 사용에 대해여 질문이 있습니다. [2]
842한귀순12/1/200922740Attempted to read or write protected memory [2]
841장근배11/30/200924535첨부 파일 Download시 한글 Name [2]
844장근배12/3/200918967    답변글 [답변]: 첨부 파일 Download시 한글 Name파일 다운로드1
840박영민11/20/200919012웹 애플리케이션 질문입니다. [1]
837left...10/21/200919547아래 게시글 관련하여 추가 질문 [3]
836left...10/19/200920428ActiveX 상에서 암시적 dll 로드 [1]
832김우진10/15/200916953C# 에서 swa + security 구현 방법이 없을까요?
833정성태10/15/200921371    답변글 [답변]: C#에서 swa + security 구현 방법이 없을까요? [1]
834김우진10/15/200917393        답변글 예제 메시지 올려드릴께요. [2]파일 다운로드1
838이영우10/30/200917281            답변글 국세청 전자세금계선서에 관하여 문의드립니다.
... 61  62  63  64  65  66  67  68  [69]  70  71  72  73  74  75  ...