LPCWSTR nach char* umwandeln, der von ExtTextOut übergeben wurde



  • Hallo,

    ich ändere mittels detours die Funktion ExtTextOut und möchte den übergebenen String abfangen.
    Jedoch klappt das umwandeln des Strings nicht, es kommen immer irgendwelche "Hyroglyphen" heraus.
    Mein Code dazu sieht so aus:

    int WINAPI Mine_ExtTextOut(HDC hdc, int x, int y, UINT options, const RECT * lprect , LPCWSTR lpwstr, UINT c, const int * lpDx )
    {
        int rv =Real_ExtTextOut(hdc, x, y, options, lprect, lpwstr, c, lpDx);
    
    	if(lpwstr==0)
    		return TRUE;
    
    	char* ascii = new char[wcslen(lpwstr) + 1];
    
    	wcstombs( ascii, lpwstr, wcslen(lpwstr) );
    	ofstream logFile("c:\\log.file", ios::out | ios::app);
    	logFile << wcslen(lpwstr) + 1 << ": " << ascii << endl;
    	delete [] ascii;
    
        return rv;
    }
    

    Wenn ich einfach einen String selber aus nem Literal erstelle, klappt es.
    Woran liegt es, dass die Umwandlung des Parameters der ExtTextOut Funktion nicht klappt?

    Bin für jede Hilfe dankbar,

    eimaa



  • wcslen(lpwstr) + 1 in wcstombs sonst kommt die 0 nich mit rein



  • Danke, löst das problem aber leider noch nicht.



  • klaro bei mir funzto es doch!



  • nupperle schrieb:

    klaro bei mir funzto es doch!

    Hast du auch die Funktion ExtTextOut detoured oder nur einen LPCWSTR erstellt und umgewandelt?
    Wenn ich den string selber erstelle, klappt es bei mir auch.


  • Mod

    Aus was hast Du Detours angewendet? Auf ExtTextOutA oder ExtTextOutW?



  • Auf die ExtTextOutW.

    Die ExtTextOutA wird nicht aufgerufen, zumindest bleibt das Logfile dann leer.


Anmelden zum Antworten