|
Hi Everyone:
Recently while I've been trying to watch the TV, there are pop-up ads that cover up the bottom quarter of the screen that occur at regular intervals. This is especially annoying when the program contains subtitles. This occurs on every commercial TV network.
Has anyone thought about making a device we can attach to our cable boxes that can filter out the pop ups? Since there is one for the internet I thought there might be one for cable TV.
I wouldn't know where to begin.
Thanks,
Quecumber256
|
|
|
|
|
I'm working on a mixed-mode project, and I came across an impossible situation today. One piece of my code managed code was not working, and I narrowed it down to the fact that it's evaluating a FALSE value as TRUE!
Don't believe me? Take a look at the screen shot of my debugger.
Line 1458 contains the IF clause that is mis-evaluating. You can see the step-trace arrow has navigated into line 1459. The very explicit comparison "...bCamFollowsTrain == true" evaluates to true even though the debugger watch window very clearly shows that bCamFollowsTrain == false. So therefore false == true!
If I continue step-tracing into the CameraMove() call at 1460, that method also contains a check on the same variable and also evaluates to "true" even though the watch window continues to show that its value is "false".
All I can think here is memory corruption. Does anyone else have any ideas? Thanks.
modified on Saturday, March 28, 2009 6:21 PM
|
|
|
|
|
I found the problem...
First, the dialog where the user can set the value of bCamFollowsTrain had backwards logic. When the "yes" radio button was selected, bCamFollowsTrain got assigned a value of FALSE, and vice versa. That's my bad. Once I fixed that, my code functioned as expected.
So then the question became "Why is the Watch window showing me the wrong value?" I inserted a line to explicitly update the value of bCamFollowsTrain just before the IF statement. In step tracing, I noticed then that the value in the Watch window shows correctly, regardless of whether I assign true or false.
The user updates this value via a modeless dialog box. Since the dialog is modeless, the update is performed by delegate callback in the RadioButton_SelectedIndexChanged event. When I removed the explicit assignment code and went back to using this dialog, the Watch window began showing the wrong value again. In fact, I was able to duplicate the situation in reverse, making the debugger show bCamFollowsTrain == TRUE when I had set it to FALSE (and when step-tracing took the FALSE path).
Therefore, my conclusion is that it seems the Watch window has some issues with picking up on variables changed via delegate callbacks. As of right now, my code is working completely as expected while my debugger is still showing incorrect values.
*sigh*
|
|
|
|
|
Hi
I currently working on building a VC++.NET wrapper for a C++ DLL. Everything compiles fine, but for some reason any methods that require pointers to be passed do not appear to be public in the wrapper class. As an example:
The prototype for a function in the C++ DLL might be:
const char* error_msg( );
so I create a corresponding function in the VC++.NET wrapper class as:
String^ o10xxBase::flash_m::error_msg()
{
return(gcnew System::String (m_flash->error_msg()));
}
This seems to work fine. Another example that requires input parameters... the prototype for the C++ function might be:
void WriteIoRegisterDW( unsigned int addr, unsigned int data );
so I create a corresponding function in the VC++.NET wrapper class as:
void o10xxBase::o10xxIo_m::WriteIoRegisterDW( unsigned int addr, unsigned int data )
{
(m_o10xxIo->WriteIoRegisterDW( addr, data ));
}
Again this works fine it seems. However if the C++ prototype requires a pointer input things don't work so well. For example, prototype for the C++ function might be:
void read_fifo( short *p_Buffer, int count );
so I create a corresponding function in the VC++.NET wrapper class as:
void o10xxBase::adi_9446_a2d_m::read_fifo( short * p_Buffer, int count )
{
(m_adi_9446_a2d->read_fifo( p_Buffer, count ));
}
This compiles with no errors, and yet the function does not appear in the wrapper class even though it is listed as public. Seems to be some issue I am overlooking with the movement of pointers from managed to unmanaged code.
Any thoughts most welcome.
Kind regards, Kurt
|
|
|
|
|
Kurt Richardson wrote: I am overlooking with the movement of pointers from managed to unmanaged code.
Maybe because there's really not any pointers in managed code
Your wrapper functions should use managed types for the arguments, not native C++ types,
otherwise other .NET languages won't be able to use your interface, which pretty much makes
a managed interface useless.
Maybe you could pass an array<Int16>^ instead, and marshal it to/from your native code if necessary...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark
I realize there are no pointers (in the C++ sense) in managed code (although getting the address of any variable is easily done), but I can't figure out what the marshal statement needs to be or even if marhsaling is needed... maybe I just pass the parameter ByVal and then just insert '&' into the C++ DLL call...
Bye for now, Kurt
|
|
|
|
|
It's ok for generic wrapper class (c++ -> cli) like this:
class Unmanaged {
...
};
namespace Wrapperspace
{
public ref class Managed {
protected:
Unmanaged *p;
public:
...
...
};
}
I could call the functions of Managed class from C# application
by just adding a reference to Wrapperspace.
But this technique didn't work for CDialog class.
class CTestDialog : CDialog {
...
};
namespace WrapperspaceDialog
{
publci ref class TestDialog {
protected:
CTestDialog *p;
public:
...
void ShowTest();
};
}
namespace WrapperspaceDialog
{
...
void TestDialog::ShowTest()
{
p = new CTestDialog();
p->Create(IDD_TESTDIALOG);
p->ShowWindow(SW_SHOW);
}
...
}
The compile is fine but when I call the ShowTest() in my application
the debug assertion failed in afxwin1.inl line 24.
Any help to write a correct wrapper class for dialog class?
Any hint will be great. Thank you in advance.
|
|
|
|
|
Oldboy2 wrote: when I call the ShowTest() in my application
the debug assertion failed in afxwin1.inl line 24.
I don't have any idea what's at that line in your framework code, but...
CDialog is an MFC class. It's also a CWnd-derived MFC class.
That means MFC needs to be properly initialized and running its message loop
for any of this to work. Have you handled those correctly?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Holy Mackerel, Mark is back!
|
|
|
|
|
<=><
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for your advice. Adding proper mfc initializing and complex project configuration, I could open the mfc dialog finally.
|
|
|
|
|
Hi,
I have a MFC application. How can i give a short cut key to a button in toolbar? Is it define in ".rc" file?
Thanks & Regards
Shaheen
|
|
|
|
|
This[^] is the best place for MFC related questions.
|
|
|
|
|
hi !! can some one help me too Write a program like patchwork that takes two characters c and d, and a positive integer n and displays the following object made of the characters c and d over n
lines and n columns, as shown below.
(in for loop if that posible)
Sample 1:
Enter two characters and an integer: $ * 3
$*$
*$*
$*$
Sample 2:
Enter two characters and an integer: / \ 6
/\/\/\
\/\/\/
/\/\/\
\/\/\/
/\/\/\
\/\/\/
=======================================
i have tried something like this
#include
using namespace std;
int main() {
int n;
char c1, c2;
cout << "Enter two characters and an integer: " << flush;
cin >> c1 >> c2 >> n;
for (int i = 2; i < n; i++)
{
cout >> c1 >> c2;
}
return 0;
}
========================================
and
#include
using namespace std;
int main() {
int n;
char c1, c2;
cout << "Enter two characters and an integer: " << flush;
cin >> c1 >> c2 >> n;
for (int i = 2; i < n; i++)
{
cout << c1 << c2 << endl;
for (int j = 2; j <= n-1 ; j++)
cout << c2 << c1 ;
cout << endl;
}
return 0;
}
=============================<pre>
but it turn ot to be different to what i want and i dont know what to do next .
|
|
|
|
|
|
I like to create an application which reads and writes data from a specific set of binary files. I choose C++/CLI because it’s easy to create a GUI with .Net but the file format is documented in c++ header files (.h).
File format is the following: Header, Header2, Data, Import, Export
Header is:
<br />
class fHeader {<br />
DWORD Id1;<br />
DWORD Id2;<br />
DWORD Id iSig;<br />
DWORD iCrc;<br />
DWORD iCompression;<br />
DWORD iFlags;<br />
LWORD iDataSize;<br />
DWORD iImportSize;<br />
DWORD iExportSize;<br />
}<br />
My idea is the following:
MBinaryFile::MBinaryFile(String^ name)<br />
{<br />
this->FileName = name;<br />
<br />
OriginalFileHeader = gcnew array<Byte>(sizeof(fHeader));<br />
<br />
FileStream^ fs = gcnew FileStream(this->FileName, FileMode::Open, <br />
FileAccess::Read);<br />
<br />
BinaryReader^ br = gcnew BinaryReader(fs);<br />
OriginalFileHeader = br->ReadBytes(OriginalFileHeader->Length);<br />
<br />
pin_ptr<Byte> pHeader = &OriginalFileHeader[0];<br />
fHeader* iOrigHdr = reinterpret_cast<fHeader*>(pHeader);<br />
<br />
Data = gcnew array<Byte>(iOrigHdr->iDataSize);<br />
Data = br->ReadBytes(Data->Length);<br />
}<br />
The problem with this approach is that every time I need to change the header I have to convert it to C++ as the pin_ptr is not able to be used as a class variable.
<br />
MBinaryFile::ChangeFlags(DWORD newFlags)<br />
{<br />
pin_ptr<Byte> pHeader = &OriginalFileHeader[0];<br />
fHeader* iOrigHdr = reinterpret_cast<fHeader*>(pHeader);<br />
<br />
iOrigHdr->iFlags = newFlags; <br />
}<br />
Creating the Header as a .Net class would be another option but I also need that to work for Header2. Header2 is a much larger C++ class with inline functions so I don’t want to convert all of the members and (inline) methods.
Is pin_ptr the way to go or is there a better way to deal with this problem?
Thanks for your help!
|
|
|
|
|
atzplzw wrote: a specific set of binary files.
all files are binary.
atzplzw wrote: My idea is the following:
What you posted after that is source code, not an idea.
Here is an idea:
Use the native C structure and native code to read the files into native memory. Then copy the values into managed memory (something CLI makes very easy in the case of doubles). This way there won't be any pinning required.
|
|
|
|
|
i guys ,
i am running a threat which will scan for worm in given directories..
currently its scanning but it supposed to show the scanned files in the listbox.. but its not showing.. how can i make it to show on list box ya..
Below is my coding :-
#pragma once
#include "Form1.h"
#include "QUARANTINE.h"
#include "Scanner.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data::SQLite;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections::Generic;
using namespace System::IO;
using namespace System::Threading;
char status ='S';
namespace Enhan_GUI {
public ref class autoscan : public System::Windows::Forms::Form
{
public:
autoscan(void)
{
InitializeComponent();
}
int Data;
protected:
~autoscan()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ cmdClose;
protected:
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Button^ cmdPause;
private: System::Windows::Forms::GroupBox^ gbxfunction;
private: System::Windows::Forms::Button^ cmdStart;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::PictureBox^ pictureBox1;
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(autoscan::typeid));
this->cmdClose = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->cmdPause = (gcnew System::Windows::Forms::Button());
this->gbxfunction = (gcnew System::Windows::Forms::GroupBox());
this->cmdStart = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->gbxfunction->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
this->SuspendLayout();
this->cmdClose->Location = System::Drawing::Point(491, 408);
this->cmdClose->Name = L"cmdClose";
this->cmdClose->Size = System::Drawing::Size(75, 23);
this->cmdClose->TabIndex = 9;
this->cmdClose->Text = L"Close";
this->cmdClose->UseVisualStyleBackColor = true;
this->cmdClose->Click += gcnew System::EventHandler(this, &autoscan::cmdClose_Click);
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Bodoni MT Poster Compressed", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(27, 16);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(123, 26);
this->label1->TabIndex = 6;
this->label1->Text = L"Click \'Start\' to Scan";
this->cmdPause->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->cmdPause->Location = System::Drawing::Point(19, 66);
this->cmdPause->Name = L"cmdPause";
this->cmdPause->Size = System::Drawing::Size(75, 23);
this->cmdPause->TabIndex = 2;
this->cmdPause->Text = L"Pause";
this->cmdPause->UseVisualStyleBackColor = true;
this->cmdPause->Click += gcnew System::EventHandler(this, &autoscan::cmdPause_Click);
this->gbxfunction->Controls->Add(this->cmdPause);
this->gbxfunction->Controls->Add(this->cmdStart);
this->gbxfunction->Location = System::Drawing::Point(31, 76);
this->gbxfunction->Name = L"gbxfunction";
this->gbxfunction->Size = System::Drawing::Size(118, 107);
this->gbxfunction->TabIndex = 7;
this->gbxfunction->TabStop = false;
this->gbxfunction->Text = L"Functions";
this->cmdStart->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->cmdStart->Location = System::Drawing::Point(19, 37);
this->cmdStart->Name = L"cmdStart";
this->cmdStart->Size = System::Drawing::Size(75, 23);
this->cmdStart->TabIndex = 1;
this->cmdStart->Text = L"Start";
this->cmdStart->UseVisualStyleBackColor = true;
this->cmdStart->Click += gcnew System::EventHandler(this, &autoscan::cmdStart_Click);
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(259, 50);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(165, 16);
this->label2->TabIndex = 10;
this->label2->Text = L"Number of Files Scanned :";
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(426, 52);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(13, 13);
this->label3->TabIndex = 11;
this->label3->Text = L"0";
this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(47, 222);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(75, 75);
this->pictureBox1->TabIndex = 12;
this->pictureBox1->TabStop = false;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::Control;
this->ClientSize = System::Drawing::Size(592, 447);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->cmdClose);
this->Controls->Add(this->label1);
this->Controls->Add(this->gbxfunction);
this->Controls->Add(this->label2);
this->Name = L"autoscan";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Sparta Av : Auto Scanning";
this->gbxfunction->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void cmdStart_Click(System::Object^ sender, System::EventArgs^ e) {
autoscan^ w = gcnew autoscan;
w->Data = 42;
Thread^ newThread = gcnew Thread( gcnew ThreadStart( w,&autoscan::ThreadFunction ) );
newThread->Start();
}
private: System::Void cmdPause_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void cmdClose_Click(System::Object^ sender, System::EventArgs^ e) {
Application::Exit();
}
void autoscan::ThreadFunction()
{
autoscan::threat();
}
void threat()
{
int count =0;
keeper=0;
ListBox^ listBox1 = gcnew ListBox;
SQLiteConnection ^connection = gcnew SQLiteConnection("Data Source=test.db3;Pooling=True");
connection->Open();
SQLiteCommand ^cmd = gcnew SQLiteCommand(connection);
cmd->CommandText = ("drop table temp");
cmd->ExecuteNonQuery();
cmd->CommandText = ("create table temp(scanid DATETIME,filename VARCHAR(250),wormname VARCHAR(50),wormtype VARCHAR(50))");
cmd->ExecuteNonQuery();
listBox1->Size = System::Drawing::Size( 392, 319 );
listBox1->Location = System::Drawing::Point( 174, 76 );
this->Controls->Add( listBox1 );
listBox1->MultiColumn = false;
listBox1->SelectionMode = SelectionMode::MultiExtended;
vector<wstring> files;
wstring directory =(L"C://NVIDIA");
if (ListFiles(directory, L"*", files))
{
for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it)
{
keepname = WStringToString(it->c_str());
searchkmp();
int index = listBox1->Items->Add(String::Concat(gcnew String(it->c_str())));
listBox1->SelectedIndex = index;
count++;
listBox1->Update();
listBox1->Refresh();
label3->Text =count.ToString();
label3->Update();
}
}
if (keeper==0)
{
System::Windows::Forms::MessageBox::Show(" No Virus is Found \n\n Your Drive is Clean");
}
if(keeper != 0)
{
System::Windows::Forms::MessageBox::Show("Number Of Virus Found : " + keeper);
}
#if defined(DEBUG)
System::Diagnostics::Debug::WriteLine( listBox1->SelectedItems[ 1 ] );
System::Diagnostics::Debug::WriteLine( listBox1->SelectedIndices[ 0 ] );
#endif
Form^ form3 = gcnew QUARANTINE();
Form::Close();
form3->Show();
}
};
}
|
|
|
|
|
its ok guys... i manage to solve that.. thanks anyway...
cheers.....
|
|
|
|
|
hi !! can some one help me to Write a C++ program like patchwork that takes two characters c and b, and a positive integer n and displays the following object made of the characters c and d over n
lines and n columns, as shown below.
(in for loop if that posible)
Sample 1:
Enter two characters and an integer: $ * 3
$*$
*$*
$*$
Sample 2:
Enter two characters and an integer: / \ 6
/\/\/\
\/\/\/
/\/\/\
\/\/\/
/\/\/\
\/\/\/
......................................................
This is what i have tried
---------------------
#include
using namespace std;
int main() {
int n;
char c, b;
cout << "Enter two characters and an integer: " << flush;
cin >> c >> b >> n;
for (int i = 2; i < n; i++)
{
cout << c << b;
}
return 0;
}
-----------
but i have no ideas waht to do next...
|
|
|
|
|
hi guys,
i am having program when i minimize then maximize a form that running a job..
My program will scan for worms in the selected directories.. when i click start it will start scanning .... while scanning it will add the scanned file names into a listbox.... if i minimize the form or open anothe windows or application (lets say my document)then click back on the form , its not showing the contents on the list box.. the list box is empty till the whole scanning process is completed...
How can i make it show the list (refresh) even after i minimize it and show it back....
and my second question is how i can allow the form to accept click on others buttons while its still scanning.. this is to allow me to stop a the scanning.... if i click on close it waits till the scanning to complete before it close...
Kindly help me...
|
|
|
|
|
Run the scanning in a separate thread. It will solve your two problems.
|
|
|
|
|
yes. if your program works in a loop, the only whey to keep your UI alive is to use the Thread.
write youre loop in a function and then run it on a thread.
sometimes 0 can be 1
|
|
|
|
|
how to run on threat i am new to this.. kindly gv me some example plz...
|
|
|
|
|
Below is my coding.. i not sure where to put the thread....
#pragma once
#include "QUARANTINE.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace Enhan_GUI {
public ref class manscan : public System::Windows::Forms::Form
{
public:
manscan(void)
{
InitializeComponent();
}
protected:
~manscan()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::GroupBox^ gbxfunction;
private: System::Windows::Forms::Button^ cmdPause;
private: System::Windows::Forms::Button^ cmdStart;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ cmdClose;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label3;
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(manscan::typeid));
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->gbxfunction = (gcnew System::Windows::Forms::GroupBox());
this->cmdPause = (gcnew System::Windows::Forms::Button());
this->cmdStart = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->cmdClose = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
this->gbxfunction->SuspendLayout();
this->SuspendLayout();
this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(47, 222);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(75, 75);
this->pictureBox1->TabIndex = 18;
this->pictureBox1->TabStop = false;
this->gbxfunction->Controls->Add(this->cmdPause);
this->gbxfunction->Controls->Add(this->cmdStart);
this->gbxfunction->Location = System::Drawing::Point(31, 76);
this->gbxfunction->Name = L"gbxfunction";
this->gbxfunction->Size = System::Drawing::Size(118, 107);
this->gbxfunction->TabIndex = 14;
this->gbxfunction->TabStop = false;
this->gbxfunction->Text = L"Functions";
this->cmdPause->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->cmdPause->Location = System::Drawing::Point(19, 66);
this->cmdPause->Name = L"cmdPause";
this->cmdPause->Size = System::Drawing::Size(75, 23);
this->cmdPause->TabIndex = 2;
this->cmdPause->Text = L"Pause";
this->cmdPause->UseVisualStyleBackColor = true;
this->cmdPause->Click += gcnew System::EventHandler(this, &manscan::cmdPause_Click);
this->cmdStart->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->cmdStart->Location = System::Drawing::Point(19, 37);
this->cmdStart->Name = L"cmdStart";
this->cmdStart->Size = System::Drawing::Size(75, 23);
this->cmdStart->TabIndex = 1;
this->cmdStart->Text = L"Start";
this->cmdStart->UseVisualStyleBackColor = true;
this->cmdStart->Click += gcnew System::EventHandler(this, &manscan::cmdStart_Click);
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(259, 50);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(165, 16);
this->label2->TabIndex = 16;
this->label2->Text = L"Number of Files Scanned :";
this->cmdClose->Location = System::Drawing::Point(491, 408);
this->cmdClose->Name = L"cmdClose";
this->cmdClose->Size = System::Drawing::Size(75, 23);
this->cmdClose->TabIndex = 15;
this->cmdClose->Text = L"Close";
this->cmdClose->UseVisualStyleBackColor = true;
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Bodoni MT Poster Compressed", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(27, 16);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(123, 26);
this->label1->TabIndex = 13;
this->label1->Text = L"Click \'Start\' to Scan";
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(426, 52);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(13, 13);
this->label3->TabIndex = 17;
this->label3->Text = L"0";
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(592, 447);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->gbxfunction);
this->Controls->Add(this->label2);
this->Controls->Add(this->cmdClose);
this->Controls->Add(this->label1);
this->Controls->Add(this->label3);
this->Name = L"manscan";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Sparta AV : Manual Scan";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->gbxfunction->ResumeLayout(false);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void cmdStart_Click(System::Object^ sender, System::EventArgs^ e) {
int count =0;
int t=0;
int refre=0;
int refres=0;
string namefile[100];
keeper=0;
ListBox^ listBox1 = gcnew ListBox;
SQLiteConnection ^connection = gcnew SQLiteConnection("Data Source=test.db3;Pooling=True");
connection->Open();
SQLiteCommand ^cmd = gcnew SQLiteCommand(connection);
cmd->CommandText = ("select * from keep");
SQLiteDataReader ^reader = cmd->ExecuteReader();
while (reader->Read())
{
String^ namekeep1 = gcnew String(reader->GetString(0));
MarshalString(namekeep1,namefile[t]);
t++;
}
reader->Close();
cmd->CommandText = ("drop table keep");
cmd->ExecuteNonQuery();
cmd->CommandText = ("create table temp(scanid DATETIME,filename VARCHAR(250),wormname VARCHAR(50),wormtype VARCHAR(50))");
cmd->ExecuteNonQuery();
listBox1->Size = System::Drawing::Size( 392, 319 );
listBox1->Location = System::Drawing::Point( 174, 76 );
this->Controls->Add( listBox1 );
listBox1->MultiColumn = false;
listBox1->SelectionMode = SelectionMode::MultiExtended;
for(int v=0;v<=t;v++)
{
vector<wstring> files;
std::wstring str2(namefile[v].length(), L' ');
std::copy(namefile[v].begin(), namefile[v].end(), str2.begin());
wstring directory = str2;
if (ListFiles(directory, L"*", files))
{
for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it)
{
keepname = WStringToString(it->c_str());
searchkmp();
int index = listBox1->Items->Add(String::Concat(gcnew String(it->c_str())));
listBox1->SelectedIndex = index;
count++;
listBox1->Update();
label3->Text =count.ToString();
label3->Update();
refre++;
}
}
}
if (keeper==0)
{
System::Windows::Forms::MessageBox::Show(" No Virus is Found \n\n Your Drive is Clean");
}
if(keeper != 0)
{
System::Windows::Forms::MessageBox::Show("Number Of Virus Found : " + keeper);
}
connection->Close();
#if defined(DEBUG)
System::Diagnostics::Debug::WriteLine( listBox1->SelectedItems[ 1 ] );
System::Diagnostics::Debug::WriteLine( listBox1->SelectedIndices[ 0 ] );
#endif
Form^ form3 = gcnew QUARANTINE();
Form::Close();
form3->Show();
}
private: System::Void cmdPause_Click(System::Object^ sender, System::EventArgs^ e) {
system("PAUSE");
}
};
}
|
|
|
|
|