CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Q:dll problem

  1. #1
    Join Date
    Apr 1999
    Posts
    19

    Q:dll problem

    I write a dll by VC++,in this dll I use DAO to operate a access database,which put a longbinary field into a access database. This dll does work in vc++ test program,but when vb program call this dll, a fatal error occured : visual basic program quits abnormally,Who can tell me why ? thanks


  2. #2
    Join Date
    Apr 1999
    Posts
    19

    Re: Q:dll problem

    Here is the code I used in my dll ,please read it,tell me what is wrong ,thanks

    if(!m_rSet_a.IsOpen()) m_rSet_a.Open();
    if(!m_rSet_a.Find(AFX_DAO_FIRST,ID)){
    m_rSet_a.Close();
    CString ID_message;
    ID_message="There has no "+ID+" in this Database";
    AfxMessageBox(ID_message);
    return FALSE;
    }

    m_rSet_a.Edit();
    FILE* f=fopen(pnFileName,"rb");
    fseek(f,0,SEEK_END);
    unsigned long len=ftell(f);
    if(len>GlobalSize(m_rSet_a.m_PIC.m_hData))
    m_rSet_a.m_PIC.m_hData=GlobalAlloc(0,len);
    char* p=(char*)GlobalLock(m_rSet_a.m_PIC.m_hData);
    fseek(f,0,SEEK_SET);
    fread(p,1,len,f);
    fclose(f);
    GlobalUnlock(p);
    m_rSet_a.m_PIC.m_dwDataLength=len;
    m_rSet_a.SetFieldDirty(&m_rSet_a.m_PIC);
    m_rSet_a.SetFieldNull(&m_rSet_a.m_PIC,FALSE);
    m_rSet_a.Update();
    ::GlobalFree(m_rSet_a.m_PIC.m_hData);
    m_rSet_a.Close();
    return TRUE;



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured