मैंने एक छोटा ऐप लिखा है जो सी # में विंडोज ओएस की सभी विंडो के टाइटलबार और टास्कबार आइकन अक्षम करता है। यहां कोड है:मैं विंडोज 7 पर जावा प्रोग्राम के टाइटलबार और टास्कबार आइकन कैसे हटा सकता हूं?
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace IconKiller
{
class Program
{
/// Import the needed Windows-API functions:
// ... for enumerating all running desktop windows
[DllImport("user32.dll")]
static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDesktopWindowsDelegate lpfn, IntPtr lParam);
private delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, int lParam);
// ... for loading an icon
[DllImport("user32.dll")]
static extern IntPtr LoadImage(IntPtr hInst, string lpsz, uint uType, int cxDesired, int cyDesired, uint fuLoad);
// ... for sending messages to other windows
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
/// Setup global variables
// Pointer to empty icon used to replace all other application icons
static IntPtr m_pIcon = IntPtr.Zero;
// Windows API standard values
const int IMAGE_ICON = 1;
const int LR_LOADFROMFILE = 0x10;
const int WM_SETICON = 0x80;
const int ICON_SMALL = 0;
static void Main(string[] args)
{
// Load the empty icon
string strIconFilePath = @"blank.ico";
m_pIcon = LoadImage(IntPtr.Zero, strIconFilePath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
// Setup the break condition for the loop
int counter = 0;
int max = 10 * 60 * 60;
// Loop to catch new opened windows
while (counter < max)
{
// enumerate all desktop windows
EnumDesktopWindows(IntPtr.Zero, new EnumDesktopWindowsDelegate(EnumDesktopWindowsCallback), IntPtr.Zero);
counter++;
System.Threading.Thread.Sleep(100);
}
// ... then restart application
Application.Restart();
}
private static bool EnumDesktopWindowsCallback(IntPtr hWnd, int lParam)
{
// Replace window icon
SendMessage(hWnd, WM_SETICON, ICON_SMALL, m_pIcon);
return true;
}
}
}
यह कोड देशी विंडोज अनुप्रयोगों के साथ ठीक काम करता प्रतीत होता है। मेरी एकमात्र समस्या यह है कि जावा स्पष्ट रूप से टास्कबार में प्रदर्शित करने के लिए अपने एप्लिकेशन आइकन के एक अलग उदाहरण का उपयोग करता है। मतलब यह है कि मेरा छोटा ऐप जावा प्रोग्राम के टाइटलबार में आइकन को हटा देता है, लेकिन टास्कबार में से एक नहीं (नेटबीन्स एक अच्छा उदाहरण है)।
उस समस्या को हल करने के लिए कैसे करें? जावा अनुप्रयोगों या उन पंक्तियों के साथ कुछ चलाने पर JFrame.setIconImage()
पर कॉल करने के लिए, विंडोज एपीआई के साथ उपयोग की जाने वाली चाल के समान, जेवीएम के माध्यम से उन कार्यक्रमों के लिए एक संदेश पास करना संभव हो सकता है?
संपादित करें: मैं सिर्फ सी # के लिए बाध्य नहीं हूं, मैं जावा में "सहायक" ऐप की तरह कुछ लिखने के लिए तैयार हूं, जिसे मैं अपने मुख्य ऐप में निष्पादित करता हूं, यह आवश्यक होना चाहिए।
मैं उत्सुक हूँ ... तुम क्यों प्रतीक है कि नेत्रहीन अनुप्रयोगों – Gus
आप इस की कोशिश की है अलग करने का एक आसान तरीका प्रदान करते हैं से छुटकारा पाने के करना चाहते हैं? http://stackoverflow.com/questions/50398/calling-c-sharp-code-from-java – Diego
@Diego यह कैसे मदद करेगा? – hvd