one hacker alone
پنج شنبه 10 فروردین 1391, 15:17 عصر
با ياد خدا
سلام من تابعي براي گرفتن عنوان پنجره فعال نوشتم كه بعد تو اينترنت كد زير رو پيدا كردم جالب بود اما متوجه نشدم دقيقا چكار كرده دوستان اگه كسي آشنايي داره ممنون ميشم توضيح بدين البته منظورم چارچوب برنامه هست نه خود كد ها چون كد مشخص هندل رو ميگيره بعد اندازه و در نهايت بعد از گرفتن عنوان با پيغام نشون ميده
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
wstring GetActiveWindowTitle()
{
wstring title;
HWND handle = GetForegroundWindow();
int len = GetWindowTextLengthW( handle )+1;
wchar_t * omgtitle = new wchar_t[len];
GetWindowTextW(handle,omgtitle,len);
title += omgtitle;
return title;
}
int main()
{
wstring loltitle;
loltitle = L"Title is: ";
loltitle += GetActiveWindowTitle();
MessageBoxW(NULL,loltitle.c_str(),L"hi",0);
return 0;
}
خطوط بزرگ رو اشكال دارم wstring نوعي داده هستن؟ خط اول چيه و چرا اينجوري تعريف شده؟
من خواستم به جاي messagebox اون رو تو همون كنسول چاپ كنم اما اين پيغام رو ميده و نميتونم cout<<loltitle رو انجام بدم
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned
short> >' (or there is no acceptable conversion)
و در آخر اينكه من انتظار داشتم اين كار به شكل زير هم انجام بشه اما برنامه حين اجرا خطا ميده
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <stdio.h>
using namespace std;
int main()
{
HWND handle = GetForegroundWindow();
int len = GetWindowTextLengthW( handle )+1;
string title;
GetWindowTextW(handle, title, len );
printf("%s",title);
return 0;
}
سلام من تابعي براي گرفتن عنوان پنجره فعال نوشتم كه بعد تو اينترنت كد زير رو پيدا كردم جالب بود اما متوجه نشدم دقيقا چكار كرده دوستان اگه كسي آشنايي داره ممنون ميشم توضيح بدين البته منظورم چارچوب برنامه هست نه خود كد ها چون كد مشخص هندل رو ميگيره بعد اندازه و در نهايت بعد از گرفتن عنوان با پيغام نشون ميده
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
wstring GetActiveWindowTitle()
{
wstring title;
HWND handle = GetForegroundWindow();
int len = GetWindowTextLengthW( handle )+1;
wchar_t * omgtitle = new wchar_t[len];
GetWindowTextW(handle,omgtitle,len);
title += omgtitle;
return title;
}
int main()
{
wstring loltitle;
loltitle = L"Title is: ";
loltitle += GetActiveWindowTitle();
MessageBoxW(NULL,loltitle.c_str(),L"hi",0);
return 0;
}
خطوط بزرگ رو اشكال دارم wstring نوعي داده هستن؟ خط اول چيه و چرا اينجوري تعريف شده؟
من خواستم به جاي messagebox اون رو تو همون كنسول چاپ كنم اما اين پيغام رو ميده و نميتونم cout<<loltitle رو انجام بدم
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned
short> >' (or there is no acceptable conversion)
و در آخر اينكه من انتظار داشتم اين كار به شكل زير هم انجام بشه اما برنامه حين اجرا خطا ميده
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <stdio.h>
using namespace std;
int main()
{
HWND handle = GetForegroundWindow();
int len = GetWindowTextLengthW( handle )+1;
string title;
GetWindowTextW(handle, title, len );
printf("%s",title);
return 0;
}