DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    Parallel Port Problems

    Hello,

    I have written the following program in MS Visual C++ running on windows XP. It is supposed to set all the data lines of my parallel port to "high" when password 2006 is entered, and "low" when 9999 is entered. I am using UserPort to get around the port access restrictions of XP. I have a multimeter hooked up to pins 2 and 18 on my computer, and I'm reading 4.2 volts no matter what I enter. Here is the code:

    Code:
    #include "stdafx.h"
    
    #include "conio.h"
    
    #include "stdio.h"
    
    #include "string.h"
    
    #include "stdlib.h" 
    
    #include <iostream>
    
    using namespace std;
    
    int main ()
    
    {
    
    int i;
    
    
    do{
    
    cout << "Please enter password: ";
    
    cin >> i;
    
    if (i == 2006) {
    
    cout << "\n Password accepted \n Unlocking door... \n";
    
    
    _outp(0x378, 255); 
    
    cout << " Door has been unlocked... \n \n \n";
    
    }
    
    else if(i == 9999){
    
    cout << "   System shutting down... \n\n\n";
    
    _outp(0x378, 0); 
    
    }
    
    else {
    
    cout << "Entry denied \n\n";
    
    }
    
    }while (i != 6606);
    
    return 0;
    
    }
    Is this code simply flawed, or is there some other issue here?

    Thanks,

    James

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    This code is designed for POSIX systems, and XP somehow supports it as a non-native extension or API. Vista is more secure and doesn't allow you to access hardware ports like this. You need to use a special library for that which essentially wraps low level hardware access with a higher level API (which is more secure and restricted).
    Danny Kalev

Similar Threads

  1. Replies: 8
    Last Post: 04-09-2007, 10:40 AM
  2. Replies: 2
    Last Post: 01-16-2006, 03:34 PM
  3. Replies: 3
    Last Post: 09-07-2002, 04:04 AM
  4. Data Reading from Parallel Port
    By Arunkumar in forum VB Classic
    Replies: 1
    Last Post: 04-29-2002, 01:23 PM
  5. Transferof String to the parallel port
    By Ali AZfar in forum VB Classic
    Replies: 4
    Last Post: 04-25-2002, 04:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links