Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    6

    DLL e Finestre Grafiche

    SALVE ragazzi...spero che riuscite a darmi una mano.
    Dovrei scrivere una dll che quando viene caricata e lanciata mi mette a video una finestra.Ora finchè uso una messagebox la cosa è semplice ma se provo prima a creare una finestra con le librerie qt e poi inserirla nella dll non so proprio come muovermi essendoci il main nella finestra qt che non so come richiamare visto che nella dll c'è il dllmain...aiutatemi...e ditemni se non sono stato chiaro..
    ciao a tutti

  2. #2
    Utente di HTML.it L'avatar di XWolverineX
    Registrato dal
    Aug 2005
    residenza
    Prague
    Messaggi
    2,565
    Metti il codice nella tua DllMain dopo aver fatto un adeguato Switch di UREASON
    "Se proprio devono piratare, almeno piratino il nostro." (Bill Gates)

    "Non è possibile che 2 istituzioni statali mi mettano esami nello stesso giorno." (XWolverineX)

    http://xvincentx.netsons.org/programBlog

  3. #3
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,303

    Moderazione

    Il regolamento impone che venga indicato il linguaggio utilizzato, soprattutto nel titolo della discussione... che linguaggio usi?


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

  4. #4
    Originariamente inviato da XWolverineX
    Metti il codice nella tua DllMain dopo aver fatto un adeguato Switch di UREASON
    Meglio di no... il codice in DllMain dovrebbe non fare praticamente niente.
    General Best Practices
    DllMain is called while the loader-lock is held. Therefore, significant restrictions are imposed on the functions that can be called within DllMain. As such, DllMain is designed to perform minimal initialization tasks, by using a small subset of the Microsoft® Windows® API. You cannot call any function in DllMain that directly or indirectly tries to acquire the loader lock. Otherwise, you will introduce the possibility that your application deadlocks or crashes. An error in a DllMain implementation can jeopardize the entire process and all of its threads.
    The ideal DllMain would be just an empty stub. However, given the complexity of many applications, this is generally too restrictive. A good rule of thumb for DllMain is to postpone as much initialization as possible. Lazy initialization increases robustness of the application because this initialization is not performed while the loader lock is held. Also, lazy initialization enables you to safely use much more of the Windows API.
    Some initialization tasks cannot be postponed. For example, a DLL that depends on a configuration file should fail to load if the file is malformed or contains garbage. For this type of initialization, the DLL should attempt the action and fail quickly rather than waste resources by completing other work.
    You should never perform the following tasks from within DllMain:
    • Call LoadLibrary or LoadLibraryEx (either directly or indirectly). This can cause a deadlock or a crash.
      Synchronize with other threads. This can cause a deadlock.
    • Acquire a synchronization object that is owned by code that is waiting to acquire the loader lock. This can cause a deadlock.
    • Initialize COM threads by using CoInitializeEx. Under certain conditions, this function can call LoadLibraryEx.
    • Call the registry functions. These functions are implemented in Advapi32.dll. If Advapi32.dll is not initialized before your DLL, the DLL can access uninitialized memory and cause the process to crash.
    • Call CreateProces. Creating a process can load another DLL.
    • Call ExitThread. Exiting a thread during DLL detach can cause the loader lock to be acquired again, causing a deadlock or a crash.
    • Call CreateThread. Creating a thread can work if you do not synchronize with other threads, but it is risky.
    • Create a named pipe or other named object (Windows 2000 only). In Windows 2000, named objects are provided by the Terminal Services DLL. If this DLL is not initialized, calls to the DLL can cause the process to crash.
    • Use the memory management function from the dynamic C Run-Time (CRT). If the CRT DLL is not initialized, calls to these functions can cause the process to crash.
    • Call functions in User32.dll or Gdi32.dll. Some functions load another DLL, which may not be initialized.
    • Use managed code.

    The following tasks are safe to perform within DllMain:
    • Initialize static data structures and members at compile time.
    • Create and initialize synchronization objects.
    • Allocate memory and initialize dynamic data structures (avoiding the functions listed above.)
    • Set up thread local storage (TLS).
    • Open, read from, and write to files.
    • Call functions in Kernel32.dll (except the functions that are listed above).
    • Set global pointers to NULL, putting off the initialization of dynamic members. In Microsoft Windows Vista™, you can use the one-time initialization functions to ensure that a block of code is executed only once in a multithreaded environment.
    Da qui.
    ---EDIT---
    Ah, anche qui, qui e da mille altre parti.
    And absolutely under no circumstances should you be doing anything as crazy as creating a window inside your DLL_PROCESS_ATTACH. In addition to the thread affinity issues, there's the problem of global hooks. Hooks running inside the loader lock are a recipe for disaster. Don't be surprised if your machine deadlocks.
    Amaro C++, il gusto pieno dell'undefined behavior.

  5. #5
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    6

    LINGUAGGIO C++

    Mi scuso di non aver inserito il linguaggio che voglio usare...in ogni caso si tratta del c++.... come programma sto usando il visual c++ 2008 express edition di microsoft...
    Ora vedo un po' i link che mi sono stati mandati...
    se qualcuo riesce mica può postarmi qualche porzione di codice di esempio...
    grazie a tutti

  6. #6
    Utente di HTML.it L'avatar di XWolverineX
    Registrato dal
    Aug 2005
    residenza
    Prague
    Messaggi
    2,565
    Originariamente inviato da MItaly
    Meglio di no... il codice in DllMain dovrebbe non fare praticamente niente.

    Da qui.
    ---EDIT---
    Ah, anche qui, qui e da mille altre parti.
    Urca, una cosa in piu' da ricordare.
    "Se proprio devono piratare, almeno piratino il nostro." (Bill Gates)

    "Non è possibile che 2 istituzioni statali mi mettano esami nello stesso giorno." (XWolverineX)

    http://xvincentx.netsons.org/programBlog

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.