Geeks With Blogs
Mehfuz Hossain Learning never stops....

i found this excellent code, that tells me how can i invoke external routine easily , using C#. The purpose of the following is to set a desktop image , on button click calling a routine from  user32.dll

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace wallpaper

{

public partial class Form1 : Form

{

[DllImport("user32.dll", CharSet = CharSet.Auto)]

private static extern Int32 SystemParametersInfo(UInt32 uiAction, UInt32 uiParam, String pvParam, UInt32 fWinIni);

private static UInt32 SPI_SETDESKWALLPAPER = 30;

private static UInt32 SPIF_UPDATEINIFILE = 0x1;

private String imageFileName = @"E:\photos\DSC01680.bmp";

public Form1()

{

InitializeComponent();

}

public void button1_Click(object sender, EventArgs e)

{


string wall = imageFileName; //+ "DSC0180.bmp";

Form1 wallset = new Form1();

wallset.SetImage(wall);

}


public void SetImage(string filename)

{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, SPIF_UPDATEINIFILE);

}

}

}

 

 source : MSDN forums Posted on Monday, May 14, 2007 7:49 PM | Back to top


Comments on this post: Calling External Procedures using C#

# re: Calling External Procedures using C#
Requesting Gravatar...
Excellent one!!
Left by Pawan Gupta on Jun 18, 2009 12:18 AM

Your comment:
 (will show your gravatar)
 


Copyright © Mehfuz Hossain | Powered by: GeeksWithBlogs.net | Join free