פורסם 2003 באוגוסט 1422 שנים רציתי לשאול אם אפשר להשתמש ב api של חלונות דרך C# (למשל כדי לנגן צליל, דבר שאני לא יודע לעשות דרך C#)?תודה
פורסם 2003 באוגוסט 1422 שנים מחבר 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 Windows 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()); } }}
פורסם 2003 באוגוסט 1522 שנים בסופו של דבר רק הכרזת על המשתנים ועל הממשק לקבצי DLL. אתה צריך להפעיל מתודה שתעשה משהוא. לדוגמא באיזור ה-); public Form1() { InitializeComponent();//Do something here }חוץ מזה אין לי מושג איך "טענת" את קבצי ה- DLL.
פורסם 2003 בספטמבר 322 שנים באתר הזה תוכל למצוא מדריך מפורט כיצד להתשמש בפונקציות API של WINDOWS ב C#:http://msdn.microsoft.com/msdnmag/issues/03/07/NET/default.aspx
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.