|
Hi
I'm writing a program for parallel port communication (in Win X)P. I've used the code in http://www.codeproject.com/system/AsefPortAccess.asp as a guideline.
When running the program, the line "_outp(0x378, iByte);" gives an error. On debugging I tracked the error to the assembly code line "1022CC4B out dx,al" which gives the error "Unhandled exception in ParallelComm.exe (MSVCRTD.DLL): 0xC0000096: Privileged Instruction."
I'd appreciate it if someone could help me out here
mirispearl
|
|
|
|
|
I know this may come as a shocking suggestion, but have you tried asking your question about using the articles code ON THE ARTICLE'S FORUM? The author will see it, and is quite likely to respond. I see he answered the last question there.
You're hoping that someone here will go to the article, download or at least read it, then answer your question.
Under NT (which XP is), you can't talk directly to the hardware from user mode, but need to go via a device driver. I'm guessing that _outp is a wrapper function around some machine code that talks directly to the I/O. Have you tried using the debugger and looking inside the function?
Iain.
|
|
|
|
|
A user program doesn't have access to the hardware in Win NT and upwards.
Check out inpout32.dll, it will take care of the problem. It can be downloaded from a lot of places, just Google for "inpout32 download".
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
thanks
worked like a charm
|
|
|
|
|
I'm glad I could help you. Good luck and thanks for letting me know.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Can any body please send some good links on mSMQ with examples using VC++
Thanks
abhi
|
|
|
|
|
|
Have you Googled for such, or checked MSDN?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Pls help me solve it...
I got this error when I compile with VS 2005, pls help me.
------ Build started: Project: VLTKLib, Configuration: Debug Win32 ------
Compiling...
pHandle.cpp
Linking...
pHandle.obj : error LNK2028: unresolved token (0A000299) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(char *,char *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAD0@Z)
pHandle.obj : error LNK2028: unresolved token (0A00029B) "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(struct HWND__ *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAUHWND__@@@Z)
pHandle.obj : error LNK2019: unresolved external symbol "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(struct HWND__ *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAUHWND__@@@Z)
pHandle.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(char *,char *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAD0@Z)
d:\workspace\VLTK\Debug\VLTKLib.dll : fatal error LNK1120: 4 unresolved externals
Build log was saved at "file://d:\workspace\VLTK\VLTKLib\Debug\BuildLog.htm"
VLTKLib - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My class:
pHandle.h
#pragma once
#include <string>
#include <stdlib.h>
#include <Windows.h>
namespace VLTKLib
{
public class pHandle
{
private:
HANDLE hProcess;
public:
pHandle(void);
pHandle(HWND curWin);
pHandle(char *winClass, char *winTitle);
~pHandle(void);
void setHandle(HWND curWin);
void setHandle(char *winClass, char *winTitle);
void closeHandle();
long ReadInt(LPBYTE lpAddress);
short ReadWord(LPBYTE lpAddress);
char ReadChar(LPBYTE lpAddress);
char *ReadString(LPBYTE lpAddress, int szChar);
};
}
pHandle.cpp
#include "StdAfx.h"
#include "pHandle.h"
#include <string>
#include <stdlib.h>
#include <Windows.h>
namespace VLTKLib
{
pHandle::pHandle(void)
{
}
pHandle::pHandle(HWND curWin)
{
setHandle(curWin);
}
pHandle::pHandle(char *winClass=NULL, char *winTitle=NULL)
{
setHandle(winClass, winTitle);
}
pHandle::~pHandle(void)
{
CloseHandle(hProcess);
}
void pHandle::setHandle(HWND curWin)
{
DWORD dwProcessID;
::GetWindowThreadProcessId(curWin, &dwProcessID);
hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE , FALSE, dwProcessID);
if (!hProcess) {
return;
}
}
void pHandle::setHandle(char *winClass=NULL, char *winTitle=NULL)
{
HWND curWin = FindWindow((LPCWSTR)winClass,(LPCWSTR)winTitle);
setHandle(curWin);
}
}
Tks a lot.
-- modified at 2:36 Monday 20th August, 2007
|
|
|
|
|
Have you used /NODEFAULTLIB linker option , by accident ?
Prasad
MS MVP - VC++
|
|
|
|
|
How to check it? I did not change any thing.
Tks for your help.
|
|
|
|
|
Check Project setting-->configuration properties-->Input-->Ignore All default lib. set it to No if, if it is yes.
Prasad
MS MVP - VC++
|
|
|
|
|
Did you import User32.lib ?
|
|
|
|
|
How to import User32.lib?
Tks for your help.
|
|
|
|
|
Right click on your project and select property on the solution window go to linker of tree list on the left panel open it and select input and enter this file at Additional Dependencies.
|
|
|
|
|
|
|
HWND curWin = FindWindow((LPCWSTR)winClass,(LPCWSTR)winTitle) - error !!!
FindWindowW(wchar_t const *,wchar_t const *)
- postfiks 'W' mean that the funktion use wchar_t instead char.
And you can convert char* to wchar_t* by using _TEXT("") macros.
And look here -> pHandle::setHandle(NULL) - wich of your function will be use?
|
|
|
|
|
Tks for your reply.
I converted all char * to wchar_t const as same as definetion of function, but I still got that errors.
void pHandle::setHandle(wchar_t const *winClass, wchar_t const *winTitle)
{
HWND curWin = FindWindow(winClass,winTitle);
setHandle(curWin);
}
Tks for your help
|
|
|
|
|
In Visual C++ 6.0, I want to run an application, such as Notepad.exe,... How must I do? Please help me!!! I'm in dark!
Thank you very much!
|
|
|
|
|
nps_ltv wrote: run an application, such as Notepad.exe,...
Here's the light You can use:
ShellExecute(/*parameters*/);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
can anybody tell me how to convert the excel format to .csv format....
|
|
|
|
|
File --> Save As...
Maxwell Chen
|
|
|
|