MD5 Tool - Copy to Clipboard Probleme

MedRamBO

Mitglied
Hi Leute,

ich hab mir heute ein kleines Win32 Tool geschrieben welches Zeichenketten MD5 crypted und dann wieder ausgibt.
Das klappt soweit ganz gut, um genau zu sein einwandfrei. Da dachte ich mir könnte man mal Userfriendly sein wie es so schön heißt und eine art "Copy to Clipboard" Funktion integrieren.
Nach ein paar Nachforschungen auf MSDN dachte ich zu wissen wie es geht, aber leider ist mein Clipbord danach immer noch leer :confused:

Könnte mir jemand aushelfen?
Danke für alle Ideeen!


Code:
#include <windows.h>
#include "stdafx.h"
#include <iostream>


using namespace std;


void main ( void )
{
	char* Uncrypted = (char*)malloc(0xC8);
	memset(Uncrypted,0,0xC8);
	char Crypted[200];

	cout<<"Please enter the String which you want to crypt: "<<endl;
	cin>>Uncrypted;

	sprintf( Crypted, "%s", MD5String( (char*)Uncrypted ) );
	
	OpenClipboard( NULL );
	EmptyClipboard();
	SetClipboardData( CF_OEMTEXT, Crypted );
	CloseClipboard();

	cout<<"\nThe output String is: "<<Crypted<<endl;
	system("PAUSE");
}
 
Warum mischt du C und C++ usw.? (u. void main gibt es nicht)

C++:
#include <windows.h>
#include "stdafx.h"

#include <iostream>

int main ()
{
    // read user input
    std::cout << "String: ";
    std::string input;
    std::getline(std::cin, input);
 
    // crypt string
    input = ::MD5String(input.c_str());
	
    // put into clipboard
    // ...
    
    std::clog << "Copied the crypted string into clipboard ...\n"
                  << "String: " << input;

    std::cin.ignore();
}
... und warum das nicht geht, mit dem in die Zwischenablage kopieren?
http://msdn.microsoft.com/en-us/library/ms649037(VS.85).aspx hat gesagt.:
Before calling EmptyClipboard, an application must open the clipboard by using the OpenClipboard function. If the application specifies a NULL window handle when opening the clipboard, EmptyClipboard succeeds but sets the clipboard owner to NULL. Note that this causes SetClipboardData to fail.
 
Zurück