ViSession   m_viRM;
    ViSession   m_vi;
    ViUInt16    stb;
    ViEventType eType;
    ViEvent     event;
    ViUInt32    timeout;

    AnsiString strTemp;
    long    status;
    long    defrm;
    long    vi;
    int     x;
    long    ArrayPrt[2];
    BYTE    ResultsArray[50000];
    long    length;
    int     fnum;
    bool    isOpen;
    long    headerlength;
    ViStatus    viErr;
    String      str;

    timeout = 3000;

    length = 50000;

    ArrayPrt[0] = length;
    ArrayPrt[1] = ResultsArray[0];

    strTemp.sprintf("%s\\PICTURE.GIF",GetCurrentDir());
    if( !DeleteFile(strTemp) )
        DeleteFile(strTemp);

    str = "TCPIP0::192.168.4.140::inst0::INSTR";

    viOpenDefaultRM ( &m_viRM );
    viErr = viOpen ( m_viRM, str.c_str(), VI_NULL, VI_NULL, &m_vi );

    if ( viErr < VI_SUCCESS )
    {
        ShowMessage("연결 실패");
        return;
    }

    status = viSetAttribute(m_vi, VI_ATTR_TMO_VALUE, 5000);

    if(status < 0)
        ShowMessage("Fail Attribute");

    status = viPrintf (m_vi, "MMEM:STOR:SCR 'C:PICTURE.GIF'\n");
    if(status < 0)
    {
        ShowMessage("Capture 실패");
        return;
    }

    viEnableEvent(m_vi, VI_EVENT_SERVICE_REQ, VI_QUEUE, VI_NULL);

    status  = viPrintf ( m_vi, "MMEM:DATA? 'C:PICTURE.GIF'\n" );
    status  = viReadSTB (m_vi, &stb);
    status  = viScanf ( m_vi, "%t", &ResultsArray );	// "% 여기에 어떤 type으로 할건지가 관건 같습니다"

    viClose(event);
    viDisableEvent(m_vi, VI_EVENT_SERVICE_REQ, VI_QUEUE);

    status = viPrintf(m_vi, ":MMEM:DEL 'C:PICTURE.GIF'\n");
    if(status < 0)
    {
        ShowMessage("삭제 실패");
        return;
    }

    viClose (m_vi);
    viClose (m_viRM);

    strTemp.sprintf("%s\\PICTURE.GIF",GetCurrentDir());
    fnum = FileCreate(strTemp);
    length = ResultsArray[1];
    strTemp.sprintf("%c",ResultsArray[1]);

    headerlength = 2 + StrToInt(strTemp);

    for(int i=headerlength; i<length-2; i++)
    {
      FileWrite(fnum, ResultsArray+i, 1);
    }
    FileClose(fnum);