winapi - How can I assign clipboard text to a variable in c++? -


i've written program highlights numbers , copies them. able basic math copied text, such multiplication or addition, can't figure out how assign clipboard data variable. basically, able copy number, assign variable "a", repeat variable "b" , multiply 2 together. have figured out how select , copy number part isn't issue. appreciated, different approach have tried.

here latest attempt @ problem:

    handle clip0;     openclipboard(null);     emptyclipboard();         clip0 = getclipboarddata(cf_text);      variable = (char)clip0;     closeclipboard(); 

where "variable" variable.

whenever run program , tell output "variable", returns value of 0.

another attempt made this:

handle clip1;     if (openclipboard(null))          clip1 = getclipboarddata(cf_text);      variable = (char)clip1;     closeclipboard(); 

but "variable" take on value of -8

the text content of clipboard c-string pointed c.

if(openclipboard(null) != false) {   handle clip0 = getclipboarddata(cf_text);    if(clip0 != null)   {     char *c = reinterpret_cast<char*>(globallock(clip0));     // use c before goes out of scope     ...     globalunlock(clip0);   }   closeclipboard(); } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -