עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

windows api ב C#

Featured Replies

פורסם

רציתי לשאול אם אפשר להשתמש ב api של חלונות דרך C# (למשל כדי לנגן צליל, דבר שאני לא יודע לעשות דרך C#)?

תודה

פורסם
  • מחבר

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());

}

}

}

פורסם

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

);

public Form1()

{

InitializeComponent();

//Do something here

}

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

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

ארכיון

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

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.