|
Hi again
I need to get hold of the parallel port address. In dos I would have used:
unsigned int far *ptraddr; /* Pointer to location of Port Addresses */
unsigned int address; /* Address of Port */
int a;
ptraddr=(unsigned int far *)0x00000408;
but this doesnt seam to work in vc6.0 (xp) - any clues as to how to do this. I would rather read in the address than just assuming it will be 0x0378.
Thanks for any advice
69Bay
|
|
|
|
|
69 Bay wrote: In dos I would have used
Well, welcome to the world of Windows.
Unless you're writing a driver for the parallel port, you cannot access an I/O port directly, you have to use a driver.
In this case you would open the parallel port as a file with ::CreateFile() with the filename "LPT1".
What are you trying to do?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Hi Roger - thanks for helping!
I have no problem reading\writing to the parallel port, using inpout32.dll. What I would like to do is find out the address of the parallel port from within the app - normally 0x0378.
I am using the parallel port simply as a digital i\o port - I need to read an input pin, and write data bytes out. I can do this no problem, but I was thinking it would be 'nice' to not have to hard code the port address, but simply read it in from somewhere, which I can do in a dos app, but not in this windows one!
Thanks again
69 Bay
|
|
|
|
|
69 Bay wrote: What I would like to do is find out the address of the parallel port from within the app - normally 0x0378.
Ok, I get what you're trying to do now.
I'd like to see it as there are two mappings to be done:
- what the user see, i.e. "parallel port 1", and how it maps to an I/O port which usually is 0x378, unless someone altered BIOS settings
- how that I/O port maps to a device name such as "LPT1"
I think it would be easier for the user if he were choosing from LPT1/LPT2 rather than different I/O ports. If the user select e.g. LPT1, then it could be assumed that the I/O port is 0x378.
However, I would try very hard to make use of the driver shipped with the OS and avoid dealing with those mappings and simply give the user the opporunity to choose from a list of LPTx.
But that's perhaps not possible in your case, it depends on what pins you're using.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Hi Roger
The user does not have the possibility of selecting either LPT1 or 2. What I am trying to do is detect what address the parallel port has been mapped to in the BIOS, so that if the setting for the parallel port in the BIOS has been altered, the app will pick up on this automatically and read\write any data out to the correct address.
thanks again
69 Bay
|
|
|
|
|
69 Bay wrote: The user does not have the possibility of selecting either LPT1 or 2.
So you're just assuming that there's only one parallel port, or you try them out one at a time?
I don't think I can help you, but you might find the article below handy. It describes how to access kernel mode address space from user mode. If you use that technique you should be able to read 0x00000408, i.e. the I/O port address of LPT1.
http://www.codeproject.com/system/soviet_kernel_hack.asp[^]
I still recommend that you use the ordinary driver for the parallel port. That way the I/O port mapping would be transparent, you would simply connect to LPT1.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Just a quickie. Whats the default behaviour of virtual methods?
If I have a classC derived from classB derived from classA, each containing the same virtual method. If classA invokes that method, what would the execution order be?
|
|
|
|
|
Only the function defined in classC will get called. The exception is for destructor, in which the destructors of classB and classA will get called also (dtor from classC then classB then classA).
|
|
|
|
|
Thanks for that. I'm going to have to re-think my code a little.
|
|
|
|
|
I am trying to get system name & ipaddress through my application in which i am working on C.
So please forward me the proper solution as soon as possible.
Can i not get ipaddress & system name in C? I know how to get this info in VC++,but that code is not running in C.The dll's are not compatible with C compiler. So please tell me how to use that code in C?
Thanks.
|
|
|
|
|
struct sockaddr_in remoteaddr;
While Accepting Client use remoteaddr structure.
Like this:
accept(l_iListener, (struct sockaddr *)&remoteaddr,&addrlen))
Then,
printf("\nClient IP address : %s",inet_ntoa(remoteaddr.sin_addr));
Sethuraman.K - Bangalore - INDIA
|
|
|
|
|
What is the system name? The computer name? GetComputerName()
What code are you using to get the IP address that doesn't work in C?
The IP Helper SDK has the GetAdaptersInfo() that will help you get info on all the adapters
on the system and their associated IP addresses. Note that if you are on a subnet behind a router
these are local addresses - to get your IP as seen on the internet requires something different.
|
|
|
|
|
If you want the host and Ip of your computer, try this:
static int GetHostIP(uint8 *IPAddress)
{
char HostName[128];
struct sockaddr_in SocketAddress;
struct hostent *pHost = 0;
if (gethostname(HostName, sizeof(HostName)) == SOCKET_ERROR)
{
return FCTSERVER_CANNOT_GET_HOST_NAME;
}
pHost = gethostbyname(HostName);
if(!pHost)
{
return FCTSERVER_CANNOT_GET_HOST_IP;
}
memcpy(&SocketAddress.sin_addr, pHost->h_addr_list[0], pHost->h_length);
strcpy(IPAddress, inet_ntoa(SocketAddress.sin_addr));
return FCTSERVER_OK;
}
|
|
|
|
|
Can someone point to some link or some suggestions on how would I be able to display a static control on the title bar of a dialog using MFC?
|
|
|
|
|
Displaying a static control on the title bar ?
What is the advantage ? Why don't you simply set the title of your dialog ?
I don't really understand what you are trying to do.
|
|
|
|
|
I have a few windows in my application and I want to display some information in the static box so that consistency is maintined. But I can't find any common space on the dialog where I can show this symmetrically. Can you suggest some other options.
|
|
|
|
|
You didn't really answer my question: why do you want to put a static control on the title bar of your dialog ? Why not simply set the title of your dialog ?
|
|
|
|
|
This is because the static control would be a hyperlink. I have subclass a static control to a hyperlink control. So what I need is when the user clicks on that hyperlink control he is redirected to a different web page.
|
|
|
|
|
A hyperlink control in the title bar of your dialog. This must be really ugly and it probably confuse totally the users. Why don't you put it on the dialog ?
I really don't understand what you are trying to do.
|
|
|
|
|
I saw buttons on the titlebar see them on the codeproject maybe it some helpfuls for you
|
|
|
|
|
Hi,
i want to disply a text (CString) in RichEdit control in diffrent font.
so can anybody Please tell me How to do it?
Thanks in advance
|
|
|
|
|
|
hi,
pls anybody tell me about windowless mode?what is the relationship between DirectX and windowless mode??
Thanks in advance
Siddharth
|
|
|
|
|
What do you mean 'windowless'? In directX there must be a window. I'm guessing you are talking about fullscreen mode? In which case there is still a window.
|
|
|
|
|
Hello, I am using VC++2005 with this line of code to load a bitmap which is already added as a resource file:
m_hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), "res/Image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
But when I execute the compiled exe file, it throws this error "Error loading Bitmap" and I have create a "res" folder and copy "Image.bmp" into it for the executable to run properly.
Does anyone know how to integrate the folder into sigle executable file?
Thanks in advance!
Lantianman
|
|
|
|