473,508 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My loop doesn't work, need some guidance..

9 New Member
The loop below doesn't work, I was wondering if anyone can help me. I need to create an infinate loop around the while condition.
The error states that 'd' is undeclared

Thank you all :)

Expand|Select|Wrap|Line Numbers
  1. #include "windows.h"
  2. #include "winioctl.h"
  3. #include <string>
  4. #include <iostream>
  5. using std::string;
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.  
  12.  
  13.  string sdrive("\\\\.\\e:");          
  14.  
  15.  HANDLE hcd = CreateFile(sdrive.c_str(), 
  16.   GENERIC_READ, 
  17.   FILE_SHARE_READ,
  18.   NULL, 
  19.   OPEN_EXISTING, 
  20.   FILE_ATTRIBUTE_READONLY, 
  21.   NULL);
  22.  
  23.  
  24.  
  25.  
  26. while(1)
  27. {
  28.  
  29.  DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
  30.     &d,NULL);
  31.  DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0,
  32.     &d,NULL);
  33.  
  34. }
  35. CloseHandle(hcd);
  36.    return 0;
  37.  
  38. }
Feb 19 '08 #1
3 1521
weaknessforcats
9,208 Recognized Expert Moderator Expert
Well, define d.

BTW: You are not using <tchar.h> and none of the TCHAR mappings. All Windows is Unicode and this ASCII stuff you are writing is converted to Unicode by the ASCII Win32 function wwho then calls the Unicode verison of that Win32 function, and then converts any returned Unicide strings back to ASCII and then returns to you.

You have to use <tchar>. That means _tmain(), etc...
Feb 19 '08 #2
cosmos22
9 New Member
Well, define d.

BTW: You are not using <tchar.h> and none of the TCHAR mappings. All Windows is Unicode and this ASCII stuff you are writing is converted to Unicode by the ASCII Win32 function wwho then calls the Unicode verison of that Win32 function, and then converts any returned Unicide strings back to ASCII and then returns to you.

You have to use <tchar>. That means _tmain(), etc...
I've defined d, so is it not possible to implement a loop in this program using what I've made? How would I go about using the <tchar.h> variable?
Feb 19 '08 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
The d is the seventh argument in the call to DeviceIoControl and it is not defined in your code. That has nothing to so with being a loop.

As to tchar.h, read this: http://msdn2.microsoft.com/en-us/lib...42(VS.85).aspx.
Feb 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4653
by: Knocked Wood | last post by:
Hi, I looked around and can't find anything on this at all and can not get it to work for IE. I'm trying to loop multiple sounds on a game, with three unique variables, when a link is clicked....
47
12035
by: Mountain Bikn' Guy | last post by:
Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) {...
3
2200
by: Liz Malcolm | last post by:
Hello and TIA for guidance. I am building a reusable search procedure (thanks go to Graham Thorpe for his example that set me on my way). Everything works up until the 2nd match is found, the...
63
3153
by: Aaron Ackerman | last post by:
What is the sytax for exiting a for loop in C#?
4
4132
by: outforblood74 | last post by:
Ok here's the deal, the for each statment using VB 6 doesn't loop all the objects. I would like it to close all the IE browsers that are open, but it doesn't work. And now I'm concerned that its...
1
2433
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.