Click here to Skip to main content
15,915,172 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Wrapper for CDialog class in C++/CLI dll Pin
Oldboy231-Mar-09 14:59
Oldboy231-Mar-09 14:59 
Questionshort cut key to a button ... Pin
m_mun25-Mar-09 23:09
m_mun25-Mar-09 23:09 
AnswerRe: short cut key to a button ... Pin
N a v a n e e t h25-Mar-09 23:32
N a v a n e e t h25-Mar-09 23:32 
Questionhelp with C++ Pin
mimikoyan25-Mar-09 18:15
mimikoyan25-Mar-09 18:15 
AnswerStop reposting your question you fraking monkey Pin
led mike26-Mar-09 4:42
led mike26-Mar-09 4:42 
QuestionCorrect handling of binary data defined in .h from a .Net perspective Pin
atzplzw25-Mar-09 9:02
atzplzw25-Mar-09 9:02 
AnswerRe: Correct handling of binary data defined in .h from a .Net perspective Pin
led mike25-Mar-09 9:47
led mike25-Mar-09 9:47 
Questionlistbox not visible in thread Pin
Thilek25-Mar-09 6:53
Thilek25-Mar-09 6:53 
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 {

	/// <summary>
	/// Summary for autoscan
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class autoscan : public System::Windows::Forms::Form
	{
	public:
		autoscan(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}
        int Data;

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~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:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		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();
			// 
			// cmdClose
			// 
			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);
			// 
			// label1
			// 
			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";
			// 
			// cmdPause
			// 
			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);
			// 
			// gbxfunction
			// 
			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";
			// 
			// cmdStart
			// 
			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);
			// 
			// label2
			// 
			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 :";
			// 
			// label3
			// 
			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";
			// 
			// pictureBox1
			// 
			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;
			// 
			// autoscan
			// 
			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 ) );



	//switch( status )
	//{
	//case 'S':
    // {
       newThread->Start();
     //  status='P';         
	//  }
    //  break;
	//case 'P':
	//   {
	 //  newThread->Suspend();
	 //  status='R';
	 //  }
    //  break;

	//   case 'R':
	 //  {
	  // newThread->Resume();
	 //  status='P';
     //  break;
	 //  }
	//default:
		//status='F';
	//} 
				 
			 }
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();// connect to databse
	SQLiteCommand ^cmd = gcnew SQLiteCommand(connection);
	cmd->CommandText = ("drop table temp");// creating temp table
	cmd->ExecuteNonQuery();

	cmd->CommandText = ("create table temp(scanid DATETIME,filename VARCHAR(250),wormname VARCHAR(50),wormtype VARCHAR(50))");// creating temp table
	cmd->ExecuteNonQuery();
	

   // Set the size and location of the ListBox.
   listBox1->Size = System::Drawing::Size( 392, 319 );
   listBox1->Location = System::Drawing::Point( 174, 76 );

   // Add the ListBox to the form.
   this->Controls->Add( listBox1 );

   // Set the ListBox to display items in multiple columns.
   listBox1->MultiColumn = false;

   // Set the selection mode to multiple and extended.
   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();
		}
	}
/*
   while (reader->Read())
   {
      String^ namekeep1 = gcnew String(reader->GetString(1));// get value from database
     int index = listBox1->Items->Add(String::Concat(namekeep1));        
			listBox1->SelectedIndex = index; 

}
*/



   if (keeper==0)
   {
    System::Windows::Forms::MessageBox::Show("  No Virus is Found \n\n Your Drive is Clean");//this close's the file if it fails to open
   }

   if(keeper != 0)
   {
   System::Windows::Forms::MessageBox::Show("Number Of Virus Found : " + keeper);//this close's the file if it fails to open
   }   
#if defined(DEBUG)
   // Display the second selected item in the ListBox to the console.
   System::Diagnostics::Debug::WriteLine( listBox1->SelectedItems[ 1 ] );

   // Display the index of the first selected item in the ListBox.
   System::Diagnostics::Debug::WriteLine( listBox1->SelectedIndices[ 0 ] );
   #endif
   		 	 Form^ form3 = gcnew QUARANTINE();
			 Form::Close();
			 form3->Show();

}
};


}

AnswerRe: listbox not visible in thread Pin
Thilek25-Mar-09 9:09
Thilek25-Mar-09 9:09 
Questionhelp with C++ pragraming Pin
mimikoyan25-Mar-09 0:56
mimikoyan25-Mar-09 0:56 
QuestionForm refresh... and accept click on button while performing other task... Pin
Thilek24-Mar-09 23:31
Thilek24-Mar-09 23:31 
AnswerRe: Form refresh... and accept click on button while performing other task... Pin
N a v a n e e t h25-Mar-09 1:14
N a v a n e e t h25-Mar-09 1:14 
AnswerRe: Form refresh... and accept click on button while performing other task... Pin
erfi25-Mar-09 2:10
erfi25-Mar-09 2:10 
GeneralRe: Form refresh... and accept click on button while performing other task... Pin
Thilek25-Mar-09 3:29
Thilek25-Mar-09 3:29 
GeneralRe: Form refresh... and accept click on button while performing other task... Pin
Thilek25-Mar-09 4:04
Thilek25-Mar-09 4:04 
GeneralRe: Form refresh... and accept click on button while performing other task... [modified] Pin
erfi25-Mar-09 11:21
erfi25-Mar-09 11:21 
QuestionProblem calling C++ DLL from Excel Pin
gvanto24-Mar-09 16:12
gvanto24-Mar-09 16:12 
QuestionDebug Assertion failed error while using an mfc dll via import library in an managed console application Pin
Muhammad.Ahmad.Malik24-Mar-09 10:02
professionalMuhammad.Ahmad.Malik24-Mar-09 10:02 
QuestionRe: Debug Assertion failed error while using an mfc dll via import library in an managed console application Pin
paxal31-Mar-09 4:02
paxal31-Mar-09 4:02 
AnswerRe: Debug Assertion failed error while using an mfc dll via import library in an managed console application Pin
Muhammad.Ahmad.Malik31-Mar-09 6:55
professionalMuhammad.Ahmad.Malik31-Mar-09 6:55 
QuestionCircular Form Reference Pin
thenutz7224-Mar-09 4:28
thenutz7224-Mar-09 4:28 
AnswerRe: Circular Form Reference [modified] Pin
led mike24-Mar-09 5:20
led mike24-Mar-09 5:20 
GeneralRe: Circular Form Reference Pin
thenutz7224-Mar-09 5:47
thenutz7224-Mar-09 5:47 
GeneralRe: Circular Form Reference Pin
led mike24-Mar-09 7:07
led mike24-Mar-09 7:07 
GeneralRe: Circular Form Reference Pin
thenutz7224-Mar-09 7:10
thenutz7224-Mar-09 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.