コード例 #1
0
ファイル: seafile-applet.c プロジェクト: simcuslee/seafile
int
set_seafile_auto_start(int on)
{
    int result = 0;
    if (on) {
        /* turn on auto start  */
        char module_name[MAX_PATH] = {0};
        DWORD len = GetModuleFileName(NULL, module_name, MAX_PATH);
        if (len == 0) {
            applet_warning("Failed to get module name\n");
            return -1;
        }
        
        char *dirname = g_path_get_dirname(module_name);
        if (!dirname) {
            applet_warning("Invalid module name\n");
            return -1;
        }
        
        char applet_path[MAX_PATH];
        snprintf (applet_path, sizeof(applet_path), "\"%s\\%s\"",
                  dirname, "seafile-applet.exe");

        result = add_to_auto_start("Seafile", applet_path);
        
        g_free (dirname);
        
    } else {
        /* turn off auto start */
        result = delete_from_auto_start("Seafile");
    }
    return result;
}
コード例 #2
0
ファイル: utils.cpp プロジェクト: beng81/seafile-client
int
set_seafile_auto_start(bool on)
{
    int result = 0;
    if (on) {
        /* turn on auto start  */
        wchar_t applet_path[MAX_PATH];
        if (GetModuleFileNameW (NULL, applet_path, MAX_PATH) == 0) {
            return -1;
        }

        result = add_to_auto_start (getBrand().toStdWString().c_str(), applet_path);

    } else {
        /* turn off auto start */
        result = delete_from_auto_start(getBrand().toStdWString().c_str());
    }
    return result;
}