Zum Inhalt springen

Miraculix

Mitglieder
  • Gesamte Inhalte

    9
  • Benutzer seit

  • Letzter Besuch

Alle Inhalte von Miraculix

  1. Schau dir doch mal das Demo TableExample an. :mod:
  2. Hallo, da gibts mehrere Möglichkeiten. Du kannst zum Beispiel die Ergebnisse der Berechnungen statt der direkten Ausgabe wieder in einem String zusammenfassen und diesen anschließend andersrum ausgeben. Die elegantere Methode ist aber wohl wenn du die Klasse Stack verwendest. In dieser speicherst du alle deine Teilergebnisse (als Integer) und gibst sie nach Abschluss der Berechnung verkehrtrum aus, indem du einfach die Elemente wieder vom Stack holst (Stack arbeitet nach der Last - In - First - Out (LIFO) Methode). mfg Andreas
  3. Miraculix

    Java

    Indem du die Variable, der du den Wert zuweisen willst vor (und nicht in) der Schleife deklarierst. Vorsicht, wenn du in der Schleife eine Variable deklarierst, die gleich heisst, wie die ausserhalb der Schleife, wird in der Schleife die lokale Variable (mit lokaler Lebensdauer) verwendet.
  4. Miraculix

    int to String

    String str = Integer.toString(i); wobei i die zu konvertierende Integer - Variable darstellt .
  5. Miraculix

    NetBeans, JBuilder & Co.

    Ich verwende ebenfalls NetBeans (allerdings meist als reinen Editor). Bin recht zufrieden damit Miraculix http://www.stud.fernuni-hagen.de/q5357322/
  6. Miraculix

    InitInstance()

    Die Methode mit FindWindow() funtioniert natürlich auch (hab gar nicht daran gedacht, obwohl ich selbst das auch mal implementiert hab - damals noch mit PASCAL with Objects). Die Sache mit den Mutex ist aber ein bisschen flexibler, weil deine Applikation in diesem Fall nicht mal ein Fenster besitzen muss (z.B ein Programm, das durch einen Registry-Eintrag im Hintergrund gestartet wird und nur als Icon in der Task-Bar sichtbar ist). Miraculix
  7. Miraculix

    InitInstance()

    Aus MSDN : HOWTO: Limit 32-bit Applications to One Instance Using C++ Q243953 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Visual C++, versions 4.0, 4.1 Microsoft Visual C++, 32-bit Enterprise Edition, versions 4.2, 5.0, 6.0 Microsoft Visual C++, 32-bit Professional Edition, versions 4.2, 5.0, 6.0 Microsoft Visual C++, 32-bit Learning Edition, version 6.0 -------------------------------------------------------------------------------- SUMMARY This article shows how to limit an application to one instance. It does not rely on any creation of windows, so the method used in this article could be used for about any 32-bit application that is developed in C++. This includes console applications, WinCE applications, dialog box based applications, applications without a graphical user interface and many others. MORE INFORMATION The method used in this article is the one described in MSDN under the WinMain topic. It uses the CreateMutex() function to create a named mutex that can be checked across processes. Instead of duplicating the same code for every application that intends to be used as a single instance, the needed code is in a C++ wrapper class that can be reused across each application. In order to use this functionality, you can use the following steps: Create a new header file with the name LimitSingleInstance.h and add it to your project. Copy the following code into the LimitSingleInstance.h file and save the file. #ifndef LimitSingleInstance_H #define LimitSingleInstance_H #include <windows.h> //this code is from Q243953 in case you lose the article and wonder //where this code came from... class CLimitSingleInstance { protected: DWORD m_dwLastError; HANDLE m_hMutex; public: CLimitSingleInstance(TCHAR *strMutexName) { //be sure to use a name that is unique for this application otherwise //two apps may think they are the same if they are using same name for //3rd parm to CreateMutex m_hMutex = CreateMutex(NULL, FALSE, strMutexName); //do early m_dwLastError = GetLastError(); //save for use later... } ~CLimitSingleInstance() { if (m_hMutex) //don't forget to close handles... { CloseHandle(m_hMutex); //do as late as possible m_hMutex = NULL; //good habit to be in } } BOOL IsAnotherInstanceRunning() { return (ERROR_ALREADY_EXISTS == m_dwLastError); } }; #endif #include the LimitSingleInstance.h file where the entry point of the program is located. If this is to be used in an MFC Application, it is the file where the InitInstance() function for the application is located. In a Win32 SDK application, it is where the WinMain() function is located. In a console application, it is where the main() function is located. #include "LimitSingleInstance.H" Create a global instance of the CLimitSingleInstance class before the entry point function. If this is being used in a MFC application, create the instance before the InitInstance() function. Pass a unique name to the constructor of the global CLimitSingleInstance instance. It is recommended to use a unique name so another application that may be using this article will not conflict when doing the duplicate checking. An easy way to get a unique name that no one else will have is to use the GUIDGEN tool. You can access the tool by typing GUIDGEN from the Start button and then select Run in Windows. If for some reason you do not have the tool, the tool is provided as a sample in MSDN. Type in GUIDGEN in the MSDN index to find it. Be sure to use the Registry Format option in the GUIDGEN tool. #include "LimitSingleInstance.H" // The one and only CLimitSingleInstance object // Change what is passed to constructor. GUIDGEN Tool may be of help. CLimitSingleInstance g_SingleInstanceObj(TEXT("{719967F0-DCC6-49b5-9C61-DE91175C3187}")); In your entry point function, call the IsAnotherInstanceRunning() method on the global instance of the CLimitSingleInstance class and check the return value. If the function returns TRUE, return from the entry point function. Otherwise, continue execution as normal. In an MFC Application, you could do something like the following: #include "LimitSingleInstance.H" // The one and only CLimitSingleInstance object CLimitSingleInstance g_SingleInstanceObj(TEXT("{05CA3573-B449-4e0b-83F5-7FD612E378E9}")); BOOL CSingleInstDlg5App::InitInstance() { if (g_SingleInstanceObj.IsAnotherInstanceRunning()) return FALSE; //rest of code } In a Console Application, you could do something like the following: #include "LimitSingleInstance.H" // The one and only CLimitSingleInstance object CLimitSingleInstance g_SingleInstanceObj(TEXT("{9DA0BEED-7248-450a-B27C-C0409BDC377D}")); int main(int argc, char* argv[]) { if (g_SingleInstanceObj.IsAnotherInstanceRunning()) return 0; //rest of code } In a Win32 SDK Application, you could do something like the following: #include "LimitSingleInstance.H" // The one and only CLimitSingleInstance object CLimitSingleInstance g_SingleInstanceObj(TEXT("{2194ABA1-BFFA-4e6b-8C26-D191BB16F9E6}")); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow) { if (g_SingleInstanceObj.IsAnotherInstanceRunning()) return FALSE; //rest of code } After following the above steps, the application will not allow more than one instance to remain active at one time. Hoffe das Hilft
  8. Miraculix

    Java Doku?

    Probier mal Go To Java 2 von Guido Krüger (gratis Download auf http://www.javabuch.de ). Empfehlenswert ist weiters JAVA ist auch eine Insel von Christian Ullenboom (gratis download von der Seite http://java-tutor.com ) Viel Spass beim lesen Miraculix

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...