我有以下课程:
class MyClass {
public:
MyClass( char* what ) : controlled( what ) {}
~MyClass() { delete[] controlled; }
operator char*() const { return controlled; }
operator void*() const { return controlled; }
operator bool() const { return controlled != 0; }
private:
char* controlled;
};
Run Code Online (Sandbox Code Playgroud)
这是使用具有以下typedef的Microsoft SDK编译的:
typedef long LONG_PTR;
typedef LONG_PTR LPARAM;
Run Code Online (Sandbox Code Playgroud)
调用代码执行以下操作:
MyClass instance( new char[1000] );
LPARAM castResult = (LPARAM)instance;
// Then we send message intending to pass the address of the buffer inside MyClass
::SendMessage( …Run Code Online (Sandbox Code Playgroud)