DLL n DLL n App Wizard MFC App

  • Slides: 13
Download presentation

일반 DLL 만들기(계속) n일반 DLL 만들기 n. App. Wizard에서 “MFC App. Wizard(dll)을 선 택

일반 DLL 만들기(계속) n일반 DLL 만들기 n. App. Wizard에서 “MFC App. Wizard(dll)을 선 택 n일반DLL을 선택할 경우 : n. Regular n DLL with MFC statically linked Regular DLL using shared MFC DLL n확장DLL인 경우 n. MFC Extended DLL (using shared MFC DLL ) 12/1/2020 동적 링크 라이브러리(DLL) 6

일반 DLL 암시적 연결하기(계속) n암시적 연결 시 DLL에 있는 함수사용 n함수선언을 함(헤더 화일에 선언)

일반 DLL 암시적 연결하기(계속) n암시적 연결 시 DLL에 있는 함수사용 n함수선언을 함(헤더 화일에 선언) extern "C" __declspec(dllexport) double Square(double d) n n. DLL에 정의된 함수 사용 n예제 n 12/1/2020 void CCall. Square. Dlg: : On. Compute() { Update. Data(); double d. Output; d. Output = Square(m_d. Input); m_str. Output. Format("%5. 2 f * %5. 2 f = %5. 2 f", m_d. Input, d. Output); Update. Data(FALSE); } 동적 링크 라이브러리(DLL) 9

일반 DLL 암시적 연결하기(계속) n명시적 연결 시 DLL에 있는 함수사용 n명시적연결 n. Load. Library

일반 DLL 암시적 연결하기(계속) n명시적 연결 시 DLL에 있는 함수사용 n명시적연결 n. Load. Library n프로그램 함수에 연결할 DLL 화일명을 기입하여 연결 예 BOOL CCall. Square. Dlg: : On. Init. Dialog() { CDialog: : On. Init. Dialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog Set. Icon(m_h. Icon, TRUE); // Set big icon Set. Icon(m_h. Icon, FALSE); // Set small icon if((m_h. Dll = Load. Library("Dll. Square. dll")) == NULL) Afx. Message. Box("Dll. Square. dll 파일을 찾을 수 없습니다. "); return TRUE; // return TRUE unless you set the focus to a control } 12/1/2020 동적 링크 라이브러리(DLL) 11

일반 DLL 암시적 연결하기(계속) n명시적 해제 n. Load. Library 함수로 로딩한 DLL의 사용이 끝난

일반 DLL 암시적 연결하기(계속) n명시적 해제 n. Load. Library 함수로 로딩한 DLL의 사용이 끝난 후 Free. Library함수를 이용하여 명시적 해제함 void CCall. Square. Dlg: : On. Destroy() { CDialog: : On. Destroy(); Free. Library(m_h. Dll); } n. DLL에 있는 함수 사용 void CCall. Square. Dlg: : On. Compute() { Update. Data(); double d. Output; typedef double (MYPROC)(double); MYPROC *p. Square; VERIFY(p. Square = (MYPROC *)Get. Proc. Address(m_h. Dll, "Square")); d. Output = (*p. Square)(m_d. Input); m_str. Output. Format("%5. 2 f * %5. 2 f = %5. 2 f", m_d. Input, d. Output); Update. Data(FALSE); } 12/1/2020 동적 링크 라이브러리(DLL) 12

Q/A Thank You 12/1/2020 동적 링크 라이브러리(DLL) 13

Q/A Thank You 12/1/2020 동적 링크 라이브러리(DLL) 13