示例#1
0
文件: CFtp.cs 项目: doctorgu/MadeIn9
        /// <summary>
        /// FTP 서버에 연결함.
        /// </summary>
        /// <param name="sServer">서버 주소</param>
        /// <param name="Port">FTP 포트</param>
        /// <param name="sUser">아이디</param>
        /// <param name="sPassword">패스워드</param>
        public void Connect(string sServer, int Port, string sUser, string sPassword)
        {
            if (hConnection != 0)
            {
                InternetCloseHandle(hConnection);
            }

            if (Port == 0)
            {
                Port = CConst.Port21Ftp;
            }

            hConnection = InternetConnect(hOpen, sServer, Port, sUser, sPassword, INTERNET_SERVICE_FTP, mConnectionMode, 0);
            if (hConnection == 0)
            {
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }
        }
示例#2
0
        private static void RegComponentByApi(string FileName, bool IsRegister)
        {
            //2011-06-07 등록 안되는 Windows 7 컴퓨터 있어 주석.
            int nLib = LoadLibraryA(FileName);

            if (nLib == 0)
            {
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            string ProcName     = IsRegister ? "DllRegisterServer" : "DllUnregisterServer";
            int    nProcAddress = GetProcAddress(nLib, ProcName);

            if (nProcAddress == 0)
            {
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            int hThread = CreateThread(0, 0, nProcAddress, 0, 0, 0);

            if (hThread == 0)
            {
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            bool Success = (WaitForSingleObject(hThread, 10000) == WAIT_OBJECT_0);

            if (!Success)
            {
                int dwExitCode = 0;
                GetExitCodeThread(hThread, dwExitCode);
                ExitThread(dwExitCode);
                FreeLibrary(nLib);
                throw new Exception(CUtil.GetLastWin32ErrorInfo());
            }

            CloseHandle(hThread);
            FreeLibrary(nLib);
        }