none
My program code called the Windows API function RRS feed

  • Question

  • My program code called the Windows API function
    If transfers this API is destroyed
    How to program should process? ?
    Sunday, February 5, 2006 10:13 AM

All replies

  • It depends on which API call you are making - could you post some code?
    Sunday, February 5, 2006 2:42 PM
    Moderator
  • //thank Ernst Kuschke :-) :-)

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

    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                Graphics g;
                IntPtr hdc = MyWindowsAPI.GetWindowDC(MyWindowsAPI.GetDesktopWindow());
                g = Graphics.FromHdc(hdc);
                Pen p = new Pen(Color.Red);
                Bitmap bp = (Bitmap)Bitmap.FromFile(@"E:\123.jpg", false);
                g.DrawImage(bp,0,0,100,100);
            }
        }
        internal class MyWindowsAPI
        {
            [System.Runtime.InteropServices.DllImport("user32.dll")]
            public static extern IntPtr GetWindowDC(IntPtr hwnd);
            [DllImport("user32.dll")]
            public extern static IntPtr GetDesktopWindow();

    ===========================================

    user32.dll GetDesktopWindow();  //destroy

    user32.dll GetWindowDC(); //destroy

    How to program should process?

     ===========================================
        }
    }

    Monday, February 6, 2006 4:29 AM