Esempio n. 1
0
/**********************************************************************
 * OpenURL  (SHDOCVW.@)
 */
void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd)
{
    InternetShortcut *shortcut;
    WCHAR* urlfilepath = NULL;
    shortcut = create_shortcut();

    if (shortcut)
    {
        int len;

        len = MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, NULL, 0);
        urlfilepath = heap_alloc(len * sizeof(WCHAR));
        MultiByteToWideChar(CP_ACP, 0, lpcstrUrl, -1, urlfilepath, len);

        if(SUCCEEDED(IPersistFile_Load(&shortcut->persistFile, urlfilepath, 0)))
        {
            URLINVOKECOMMANDINFOW ici;

            memset( &ici, 0, sizeof ici );
            ici.dwcbSize = sizeof ici;
            ici.dwFlags = IURL_INVOKECOMMAND_FL_USE_DEFAULT_VERB;
            ici.hwndParent = hWnd;

            if FAILED(UniformResourceLocatorW_InvokeCommand(&shortcut->uniformResourceLocatorW, (PURLINVOKECOMMANDINFOW) &ici))
                    TRACE("failed to open URL: %s\n.",debugstr_a(lpcstrUrl));
        }

        heap_free(shortcut);
        heap_free(urlfilepath);
    }
Esempio n. 2
0
HRESULT InternetShortcut_Create(IUnknown *pOuter, REFIID riid, void **ppv)
{
    InternetShortcut *This;
    HRESULT hr;

    TRACE("(%p, %s, %p)\n", pOuter, debugstr_guid(riid), ppv);

    *ppv = NULL;

    if(pOuter)
        return CLASS_E_NOAGGREGATION;

    This = create_shortcut();
    if (This)
    {
        hr = Unknown_QueryInterface(This, riid, ppv);
        if (SUCCEEDED(hr))
            SHDOCVW_LockModule();
        else
            heap_free(This);
        return hr;
    }
    else
        return E_OUTOFMEMORY;
}
Esempio n. 3
0
void
caja_side_pane_set_panel_image (CajaSidePane *side_pane,
                                GtkWidget *widget,
                                GdkPixbuf *pixbuf)
{
    SidePanel *panel;
    GtkWidget *image;

    g_return_if_fail (side_pane != NULL);
    g_return_if_fail (CAJA_IS_SIDE_PANE (side_pane));
    g_return_if_fail (widget != NULL);
    g_return_if_fail (GTK_IS_WIDGET (widget));
    g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));

    panel = panel_for_widget (side_pane, widget);

    g_return_if_fail (panel != NULL);

    if (pixbuf)
    {
        image = gtk_image_new_from_pixbuf (pixbuf);
        gtk_widget_show (image);
    }
    else
    {
        image = NULL;
    }

    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (panel->menu_item),
                                   image);

    if (panel->shortcut)
    {
        gtk_widget_destroy (panel->shortcut);
        panel->shortcut = NULL;
    }

    if (pixbuf)
    {
        panel->shortcut = create_shortcut (side_pane, panel, pixbuf);
        gtk_widget_show (panel->shortcut);
        gtk_box_pack_start (GTK_BOX (side_pane->details->shortcut_box),
                            panel->shortcut,
                            FALSE, FALSE, 0);
    }
}
Esempio n. 4
0
/*
 * Called if kernel wants us to create a shortcut
 */
void create_ingress_svc(uint32_t ipaddr, char *atm_addr, struct atm_qos qos)
{
	int i, new_socket;
	
        new_socket = create_shortcut(atm_addr,qos);
        if (new_socket < 0) {
                printf("mpcd: io.c: create_ingress_svc: create_shortcut failed\n");
                return;
	}
        
        for (i = first_empty; i < OPEN_MAX; i++) {
	        if (fds[i].fd >= 0)                /* slot in use ? */
                        continue;
                fds[i].fd      = new_socket;
                fds[i].events  = POLLIN | POLLOUT;
                fds[i].revents = 0;
                break;
        }
        if (i == OPEN_MAX) {
                printf("mpcd: io.c: create_ingress_svc: create_shortcut: no room for new connection\n");
                return;
        }

        socket_type[i] = (OUTGOING_SHORTCUT | CONNECTING);
        if (i >= fds_used)
                fds_used = i + 1;

        /* Store the IP address we are creating this shortcut for */
        dprintf("mpcd: io.c: create_ingress_svc: adding ip 0x%x\n", ipaddr);
        for(i = 0; i < OPEN_MAX; i++)
                if (ingress_shortcuts[i].state == INGRESS_NOT_USED)
		        break;

        if (i == OPEN_MAX) {
                printf("mpcd: io.c: create_ingress_svc: ingress no more entries\n");
                return;
        }

        ingress_shortcuts[i].fd     = new_socket;
        ingress_shortcuts[i].ipaddr = ipaddr;
        ingress_shortcuts[i].state  = INGRESS_CONNECTING;
}
Esempio n. 5
0
HRESULT WINAPI InternetShortcut_Create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
    InternetShortcut *This;
    HRESULT hres;

    TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);

    *ppv = NULL;

    if(outer)
        return CLASS_E_NOAGGREGATION;

    This = create_shortcut();
    if(!This)
        return E_OUTOFMEMORY;

    hres = Unknown_QueryInterface(This, riid, ppv);
    Unknown_Release(This);
    return hres;
}
Esempio n. 6
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	try
	{
		CoInitialize(NULL); 
		string common_programs = get_special_folder_path(NULL, CSIDL_COMMON_PROGRAMS, true) + "\\Command & Conquer";
		CreateDirectory(common_programs.c_str(), NULL);
		Creg_key key_ea_games(HKEY_LOCAL_MACHINE, "SOFTWARE\\Electronic Arts\\EA Games", KEY_QUERY_VALUE | KEY_SET_VALUE);
		Creg_key key_tfd(HKEY_LOCAL_MACHINE, "SOFTWARE\\Electronic Arts\\EA Games\\Command and Conquer The First Decade", KEY_QUERY_VALUE);
		Creg_key key_westwood(HKEY_LOCAL_MACHINE, "SOFTWARE\\Westwood", KEY_QUERY_VALUE | KEY_SET_VALUE);
		try
		{
			Cgame td(key_tfd, "cc_");
			Creg_key(key_westwood, "Command & Conquer Windows 95 Edition", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", td.m_folder + "\\" + td.m_executable);
			create_shortcut(td.m_folder + "\\" + td.m_executable, td.m_args, common_programs + "\\Tiberian Dawn.lnk");
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame ra(key_tfd, "ra_");
			Creg_key(key_westwood, "Red Alert Windows 95 Edition", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", ra.m_folder + "\\" + ra.m_executable);
			create_shortcut(ra.m_folder + "\\" + ra.m_executable, ra.m_args, common_programs + "\\Red Alert.lnk");
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame ts(key_tfd, "ts_");
			Creg_key(key_westwood, "Tiberian Sun", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", ts.m_folder + "\\" + ts.m_executable);
			create_shortcut(ts.m_folder + "\\" + ts.m_executable, ts.m_args, common_programs + "\\Tiberian Sun.lnk");
			DeleteFile((ts.m_folder + "\\woldata.key").c_str());
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame ra2(key_tfd, "r2_");
			Creg_key(key_westwood, "Red Alert 2", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", ra2.m_folder + "\\" + ra2.m_executable);
			create_shortcut(ra2.m_folder + "\\" + ra2.m_executable, ra2.m_args, common_programs + "\\Red Alert 2.lnk");
			DeleteFile((ra2.m_folder + "\\woldata.key").c_str());
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame ra2_yr(key_tfd, "yr_");
			Creg_key(key_westwood, "Yuri's Revenge", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", ra2_yr.m_folder + "\\" + ra2_yr.m_executable);
			create_shortcut(ra2_yr.m_folder + "\\" + ra2_yr.m_executable, ra2_yr.m_args, common_programs + "\\Yuri's Revenge.lnk");
			DeleteFile((ra2_yr.m_folder + "\\woldata.key").c_str());
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame rg(key_tfd, "rn_");
			Creg_key(key_westwood, "Renegade", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", rg.m_folder + "\\" + rg.m_executable);
			create_shortcut(rg.m_folder + "\\" + rg.m_executable, rg.m_args, common_programs + "\\Renegade.lnk");
			DeleteFile((rg.m_folder + "\\woldata.key").c_str());
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame gr(key_tfd, "gr_");
			Creg_key(key_ea_games, "Generals", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", gr.m_folder + "\\");
			create_shortcut(gr.m_folder + "\\" + gr.m_executable, gr.m_args, common_programs + "\\Generals.lnk");
		}
		catch (exception&)
		{
		}
		try
		{
			Cgame gr_zh(key_tfd, "zh_");
			Creg_key(key_ea_games, "Command and Conquer Generals Zero Hour", KEY_QUERY_VALUE | KEY_SET_VALUE).set_value("InstallPath", gr_zh.m_folder + "\\" + gr_zh.m_executable);
			create_shortcut(gr_zh.m_folder + "\\" + gr_zh.m_executable, gr_zh.m_args, common_programs + "\\Zero Hour.lnk");
		}
		catch (exception&)
		{
		}
	}
	catch (exception&)
	{
		return 1;
	}
	return 0;
}
Esempio n. 7
0
/**
 * Main entry for program.
 *
 * @param argc Number of command line arguments
 * @param argv Command line arguments
 * @return 0 on success
 */
int
main (int argc, char* argv[])
{
  char *option;
  int result;
  char *sparam1=NULL, *sparam2, *sparam3, *sparam4;
  char *sparam5, *sparam6, *sparam7, *sparam8, *sparam9;
#ifdef _WIN32
  char path[MAX_PATH];
#endif
  int iparam1, iparam2;
  long lparam1;

  /****************************************************************************
   * Show program help
  ****************************************************************************/
  if (get_option (argv, argc, "--help", NULL) == 0)
    {
      usage (stdout);
      exit (0);
    }
  /****************************************************************************
   * Read command line options from file
  ****************************************************************************/
  if (get_option (argv, argc, "-file", &option) == 0)
    {
      result = read_file_options (option);
      free (option);
      if (result == -1)
        fail ("Failed to read options file: %s.", option);
    }
  /****************************************************************************
   * Enable logging
  ****************************************************************************/
  if (get_option (argv, argc, "-log", &option) == 0)
    {
      logFile = fopen (option, "a");
      if (logFile == NULL)
        fail ("Failed to write log file: %s", option);
      free (option);
    }
  /****************************************************************************
   * Wait for process to terminate
  ****************************************************************************/
  if (get_option (argv, argc, "-pid", &option) == 0)
    {
      iparam1 = -1;
      lparam1 = atoi (option);
      free (option);
      if (get_option (argv, argc, "-wait", &option) == 0)
        {
          iparam1 = atoi (option);
        }
      if (wait_for_pid (lparam1, iparam1) != 0)
        fail ("Timed out waiting for process to terminate.");
      free (option);
    }
  /****************************************************************************
   * Remove directories
  ****************************************************************************/
  if (get_option (argv, argc, "-removeDir", &option) == 0)
    {
      result = delete_directories (option, 0);
      if (result != 0)
        fail ("Failed to delete directories: %s", option);
      else
        log_message ("-removeDir %s", option);
      free (option);
    }
  /****************************************************************************
   * Remove directories if they are empty
  ****************************************************************************/
  if (get_option (argv, argc, "-removeEmptyDir", &option) == 0)
    {
      result = delete_directories (option, 1);
      if (result != 0)
        fail ("Failed to delete empty directories: %s", option);
      else
        log_message ("-removeEmptyDir %s", option);
      free (option);
    }
  /****************************************************************************
   * Set registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regSetValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_argument (NULL);
      sparam4 = get_argument (NULL);
      result = set_registry_value (sparam1, sparam2, sparam3, sparam4);
      if (result != 0)
        fail ("Failed to set registry value.");
      else
        log_message ("-regSetValue %s, %s, %s, %s", sparam1, sparam2,
          sparam3, sparam4);
      free (option);
#else
      fail ("-regSetValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Get registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regGetValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_registry_value (sparam1, sparam2);
      if (sparam3)
        puts (sparam3);
      else
        fail ("Failed to get registry value %s, %s.", sparam1, sparam2);
      free (option);
#else
      fail ("-regSetValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Delete registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regDeleteValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      result = delete_registry_value (sparam1, sparam2);
      if (result != 0)
        fail ("Failed to delete registry value.");
      else
        log_message ("-regDeleteValue %s, %s", sparam1, sparam2);
      free (option);
#else
      fail ("-regDeleteValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Delete registry key
  ****************************************************************************/
  if (get_option (argv, argc, "-regDeleteKey", &option) == 0)
    {
#ifdef _WIN32
      result = delete_registry_key (option);
      if (result != 0)
        fail ("Failed to delete registry key.");
      else
        log_message ("-regDeleteKey %s", option);
      free (option);
#else
      fail ("-regDeleteKey is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Run as administrator
  ****************************************************************************/
  if (get_option (argv, argc, "-runAdmin", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);

      result = -1;
      if ((sparam1 != NULL) && (sparam2 != NULL))
      {
        replace_chars (sparam2, '\'', '"');
        result = run_admin (sparam1, sparam2);
      }
      if (result != 0)
        fail ("Failed to run program.");
      else
        log_message ("-runAdmin %s,%s", sparam1, sparam2);
      free (option);
#else
      fail ("-runAdmin is currently only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Create short-cut
  ****************************************************************************/
  if (get_option (argv, argc, "-createShortcut", &option) == 0)
    {
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_argument (NULL);
      sparam4 = get_argument (NULL);
      sparam5 = get_argument (NULL);
      sparam6 = get_argument (NULL);
      sparam7 = get_argument (NULL);
      sparam8 = get_argument (NULL);
      sparam9 = get_argument (NULL);
      if (strlen (sparam6) != 0)
        iparam1 = atoi (sparam6);
      else
        iparam1 = 0;
      if (strlen (sparam9) != 0)
        iparam2 = atoi (sparam9);
      else
        iparam2 = 0;
      result = create_shortcut (sparam1, sparam2, sparam3, sparam4, sparam5,
        iparam1, sparam7, sparam8, iparam2);
      if (result != 0)
        fail ("Failed to create shortcut.");
      else
        log_message ("-createShortcut %s, %s, %s, %s, %s, %s, %s, %s %s",
          sparam1, sparam2, sparam3, sparam4, sparam5, sparam6, sparam7,
          sparam8, sparam9);
      free (option);
    }
  /****************************************************************************
   * Get special folder
  ****************************************************************************/
  if (get_option (argv, argc, "-getSpecialFolder", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      iparam1 = get_clsid (sparam1);
      result = get_special_folder (iparam1, path);
      free (option);
      if (result != 0)
        fail ("Failed to get special folder: %s", sparam1);
      else
        puts(path);
#else
      fail ("-getSpecialFolder is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Get property
  ****************************************************************************/
  if (get_option (argv, argc, "-getOsProperty", &option) == 0)
    {
      sparam1 = get_argument (option);
      print_os_property (sparam1);
      free (option);
    }

  if (logFile != NULL)
    fclose (logFile);
  if (fargv != NULL)
    free (fargv);

  return EXIT_SUCCESS;
}