⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kceasy_p.cpp

📁 Last change: 2008-02-03 This is the source code of KCeasy。
💻 CPP
字号:
/*
This file is part of KCeasy (http://www.kceasy.com)
Copyright (C) 2002-2004 Markus Kern <mkern@kceasy.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
*/
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "kceasy.rc" // for mutex and msg target names

static const UINT WM_KCEASY_EXTERNAL_SHOW = WM_USER + 1; // also change in KCeasy.h
//---------------------------------------------------------------------------
USEFORM("src\KCeasy.cpp", MainForm);
USEFORM("src\BrowserPage.cpp", BrowserForm);
USEFORM("src\SearchPage.cpp", SearchForm);
USEFORM("src\TransferPage.cpp", TransferForm);
USEFORM("src\LibraryPage.cpp", LibraryForm);
USEFORM("src\PlayerPage.cpp", PlayerForm);
USEFORM("src\StatusPage.cpp", StatusForm);
USEFORM("src\AboutDialog.cpp", AboutForm);
USEFORM("src\ConfigDialog.cpp", ConfigForm);
USEFORM("src\UpdateForm.cpp", AutoUpdate);
USEFORM("src\ShareSelectDialog.cpp", ShareSelectForm);
USEFORM("src\SearchResultPage.cpp", SearchResultForm); /* TForm: File Type */
USEFORM("src\ConfigWizard.cpp", ConfigWizardForm);
USEFORM("src\BanlistUpdate.cpp", BanlistUpdateForm);
USEFORM("src\MagnetDialog.cpp", MagnetForm);
USEFORM("src\ChatPage.cpp", ChatForm);
USEFORM("src\ChatChannelPage.cpp", ChatChannelFrame); /* TFrame: File Type */
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HANDLE hGlobalMutex = NULL;

    try
    {
        // is there another instance running?
        if((hGlobalMutex = OpenMutex(SYNCHRONIZE,FALSE,BRAND_GLOBAL_MUTEX_NAME)) != NULL) {
            // close mutex handle
            CloseHandle(hGlobalMutex);
            // bring it to foreground if possible
            HWND hMsgTargetWnd = FindWindow("MessageTarget",BRAND_EXTERNAL_MSG_TARGET);
            if(hMsgTargetWnd)
                PostMessage(hMsgTargetWnd,WM_KCEASY_EXTERNAL_SHOW,0,0);
        } else {
            // create mutex and acquire it
            hGlobalMutex = CreateMutex(NULL,TRUE,BRAND_GLOBAL_MUTEX_NAME);
            // run application
            Application->Initialize();
            Application->Title = "";
         Application->CreateForm(__classid(TMainForm), &MainForm);
         Application->Run();
            // release mutex, if giFTl has mutex opened it will now be signaled to terminate
            ReleaseMutex(hGlobalMutex);
            CloseHandle(hGlobalMutex);
        }
    }
    catch (Exception &exception)
    {
        CloseHandle(hGlobalMutex);
        Application->ShowException(&exception);
    }
    catch (...)
    {
        CloseHandle(hGlobalMutex);
        try
        {
            throw Exception("");
        }
        catch (Exception &exception)
        {
            Application->ShowException(&exception);
        }
    }
    return 0;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -