Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can access my USB device from command prompt manually by appending a .bsc file as shown

C:\a\TestDriveRead\TestDriveRead\Debug>TestDriveRead.exe G: TestDriveRead.bsc

I'm unable to debug and access from using visual studio directly .
How do i append "G: TestDriveRead.bsc" into code below
Please help me out.



C++
#include "stdafx.h"
#include "windows.h"
#include <iostream>
#include "conio.h"


FILE *mpe;
FILE *mpeout;
int i,lloop=0,nRet,data,count=0;
unsigned char buffer[10 * 1024  * 1024];
char drive[10];

DWORD dwBytes;
	
int main(int argc, char* argv[])
{
 HANDLE m_hDrive; 
 printf("-----------------------------------------------------------------------------\n");
 
 printf( " %s\n",&logo);
 getch();

 
 if ( !(strcmp(argv[0],"c")) || !(strcmp(argv[1],"C:")) || !(strcmp(argv[1],"d:")) || !(strcmp(argv[1],"D:")) || !(strcmp(argv[1],"e:")) || !(strcmp(argv[1],"E:")) || !(strcmp(argv[1],"f:")) || !(strcmp(argv[1],"F:")))	
 {
	printf(" Caution Drive should be D: and above \n");
	return 1;
 }
 
  strcpy(drive,"\\\\?\\");
  strcat(drive,argv[1]);
 

   mpe= fopen(argv[2],"rb");
    if ( mpe == NULL )
  {
    printf(" Error openning File %s \n",argv[2]);
	
	return 1;
  }
	  
  mpeout= fopen("mpedata.dat","wb");
  if ( mpeout == NULL )
  {
	printf(" Error creating output File \n");
	return 1;
  }
	
#if 1
	m_hDrive = CreateFile(drive,
    GENERIC_READ | GENERIC_WRITE, // open for reading 
    0, // do not share 
    0, // default security 
    OPEN_EXISTING, // overwrite existing 
    0,
    0); // no attr. template 

	if( m_hDrive == INVALID_HANDLE_VALUE)
	{
		
		printf("Could not open the file error %d \n",GetLastError());
		return 0;
	}
}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 9-Jul-14 8:26am
v2

You don't: assuming you want to run the code in the debugger instead of in a command window, then you need to set the runtime arguments for the debug application.
It's pretty simple:
  • Open your project in Visual Studio

  • Right click the EXE project, and select "Properties"

  • In the dialog that appears select "Configuration Properties...Debugging" on the left hand side

  • Enter "G: TestDriveRead.bsc" as the "Command Argumnts" and click OK

Now when you run your app in the debugger, you will get the arguments passed as if you had typed them each time.
 
Share this answer
 
Comments
AshwinK4 10-Jul-14 0:53am    
I have tried the above procedure but i am not able to release the exe. Please suggest some changes in the code that could append G: TestDriveRead.bsc.
Thank you
just added strcpy(drive,"\\\\?\\G:");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900