반응형
	/// <summary>
        /// 외부에서 장치들의 상태를 알아오는 함수를 호출 할 수 있는 모듈
        /// </summary>
        /// <param name="str"></param>
        /// <param name="len"></param>
        [DllImport("SetupApiDll.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
        private static extern void GetDeviceInfo(StringBuilder str, int len);

        /// <summary>
        /// 장치들의 상태를 알아온다.
        /// </summary>
        /// <returns>장치들의 상태를 문자열로 돌려준다.</returns>
        public string GetDeviceState()
        {
            StringBuilder buffer = new StringBuilder(255);
            GetDeviceInfo(buffer, buffer.Capacity);
            return buffer.ToString();
        }

장치 정보가져오는 dll을 DllImport할 때 빌드한 컴퓨터에서는 동작이 잘되었지만

다른 컴퓨터에서 실행하니 dll을 찾을 수 없다는 오류가 발생하였다.

확인해보니 해당 dll을 참조하는 dll을 추가해 주어야 정상 동작하였다.

msvcpr100d.zip
0.74MB

설치 프로젝트를 만들 때 해당 dll들을 포함시켜 빌드하여 오류를 해결하였다. (zip파일 바이러스 검사하였음)

 

-------- 윈도우 시스템 폴더에 포함시켜도 동작하였다 ------

win 32bit 일 경우 C:\Windows\system32 폴더안에 복사

win 64bit 일 경우 C:\Windows\syswow64 폴더안에 복사

 

참고로 아래 사이트에서 무료로 특정 dll이 참조하는 다른 dll을 찾아주는 프로그램도 있다.

http://www.dependencywalker.com/

 

Dependency Walker (depends.exe) Home Page

Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that modul

www.dependencywalker.com

노란색 ? 동그라미로 표시된 dll이 없는 dll이라는 것을 알 수 있다.

반응형

+ Recent posts