windows api ב C# - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

windows api ב C#


k-o-b-y

Recommended Posts

OK אנהבנתי איך להוסיף את לטעון את הקבצי dll (עם DLLImport) ולהגדיר את הפונקציות והצלחתי לנגן wav עם sndPlaySound.

אבל יש פונקציות מסויימות שמבקשות פרמטר hdc מסוג long. מצאתי ב Graphics מתודה GetHdc אבל היא מסוג IntPtr. ניסיתי את הפונקציה RoundRect וניסיתי להמיר את ה GetHdc ל long אבל זה לא עובד.

הנה הקוד אולי משהו יבין למה זה לא עובד:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Runtime.InteropServices;

namespace DLL_load

{

public class Form1 : System.Windows.Forms.Form

{

private System.ComponentModel.Container components = null;

[DllImport("WINMM.DLL", EntryPoint="sndPlaySoundA",CharSet=CharSet.Ansi)]

private static extern long PlaySound(string lpszSoundName, long uFlags);

[DllImport("gdi32.DLL", EntryPoint="RoundRect",CharSet=CharSet.Ansi)]

private static extern long RoundRect(long hdc, long X1, long Y1, long X2, long Y2,long X3, long Y3);

public Form1()

{

InitializeComponent();

}

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Form Designer generated code

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.Size = new System.Drawing.Size(300,300);

this.Text = "Form1";

//PlaySound("D:\\software\\3d\\ATI Demos\\Bear\\Audio\\BearLoop.wav",0);

this.MouseDown += new MouseEventHandler(this.paintRect);

}

#endregion

private void paintRect(object Sender, MouseEventArgs e)

{

MessageBox.Show("H");

RoundRect((long)this.CreateGraphics().GetHdc(),2,2,5,2,5,2);

}

[sTAThread]

static void Main()

{

Application.Run(new Form1());

}

}

}

קישור לתוכן
שתף באתרים אחרים

בסופו של דבר רק הכרזת על המשתנים ועל הממשק לקבצי DLL. אתה צריך להפעיל מתודה שתעשה משהוא. לדוגמא באיזור ה-

);

public Form1()

{

InitializeComponent();

//Do something here

}

חוץ מזה אין לי מושג איך "טענת" את קבצי ה- DLL.

קישור לתוכן
שתף באתרים אחרים

  • 3 שבועות מאוחר יותר...

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...