|
Hello,
I'm using Visual C++ 6, and I'm trying to duplicate my work from the Borland complier. I want to hook interrupt functions via the 'interrupt' keyword but it seems the Visual complier does not support this keyword. Also I've tried using _dos_getvect() and _dos_setvect() but again the complier won't have it.
Is it possible to do what I'm trying to do under Visual C++ 6?
The project I built is Win32 console application.
Many thanks for any help.
|
|
|
|
|
Joe_G wrote:
Also I've tried using _dos_getvect() and _dos_setvect() but again the complier won't have it.
That's because those are old 16-bit conventions. You can do inline assembler using the _asm keyword.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I hope you know that interrupt handling and hardware access are very different in the Win32 environment than your experience under MS-DOS (which I'm guessing from the _dos_getvect() and _dos_setvect() references in your message).
Your problems with the compiler are deliberate choices on Microsoft's part. VC6 is designed to produce only executables that run in a Windows environment, so they saw no need to provide hardware access. You won't find library support for interrupts or port I/O. You can achieve these things using _asm blocks, of course, but that leads us to the next problem.
As a rule, the Win32 environment disallows hardware access by applications. Period. The purpose of this is to protect system integrity from ill-behaved applications. Now, there are differences depending upon which version of Windows you are developing for.
I've not programmed for it in a long while, but there may be enough of the DOS subsystem present to let you play with the interrupts under Windows 9x/ME. There are constraints, but I don't know if they completely prevent you from accessing the interrupt structure.
Under Windows NT/2000/XP, you are completely out of luck. NT and its successors reserve interrupt access to device drivers only. The best thing that will happen to your application if it tries to replace/intercept an interrupt is that it will terminate with an exception.
If you absolutely have to deal with hardware directly, you're going to have to learn about device drivers in the Win32 environment, which is distinctly non-trivial.
Software Zen: delete this;
|
|
|
|
|
I have a string specifying the user name in the format: "domain\username". My question is: How can I get the group to witch the user belongs to?
I searched API's but couldn't find anything all I could find was "LookupAccountName" but it is not what I'm looking for. Please help if you know something. Thank's
|
|
|
|
|
LookupAccountSid() is but one way. NetUserGetInfo() is another.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
This is good, but it seems to work only for local users. It doesn't work for a user on a diffrent domain for exaple if my computer name is "Station" and it belongs to the "LAN" domain and there is a user on the domain "LAN" called "globalUser" and a user on the local machine called "localUser", the function fill fail if I try to look up the user "LAN\globalUser". Even more, NetUserEnum() will not show the user called "globalUser".
|
|
|
|
|
I can use the following to get all users on my PDC:
LPUSER_INFO_0 pUserInfo = NULL,
pUserInfoTemp = NULL;
NET_API_STATUS nStatus;
DWORD dwIndex,
dwEntriesRead,
dwTotalEntries,
dwResumeHandle = 0;
CString strText;
nStatus = NetUserEnum(_T("\\\\tulsant"), 0, 0, (LPBYTE *) &pUserInfo, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
if (nStatus == NERR_Success || nStatus == ERROR_MORE_DATA)
{
pUserInfoTemp = pUserInfo;
if (NULL != pUserInfoTemp)
{
for (dwIndex = 0; dwIndex < dwEntriesRead; dwIndex++)
{
if (NULL == pUserInfoTemp)
break;
strText = pUserInfoTemp->usri0_name;
m_cbUserList.AddString(strText);
pUserInfoTemp++;
}
}
}
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Yes, this works fine for local users but I want to list even the users on other domains. It must be possible beacause in Win2000 when I go to "Control Panel\Users and Passwords\Add\Browse"
it shows me a list of all users on my domain but NetUserEnum() only enumerates the users that are stored on my computer.
|
|
|
|
|
The code snippet I provided is for iterating the userlist on the listed domain controller. If it is not working for you, something else is at play. How are you using the NetUserEnum() function?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
NetUserGetGroups or IADsUser::Groups
|
|
|
|
|
I want to do some printing randomly, each time print a single line.
When I use EndDoc() or Escape(ENDDOC), the printer ends a page.
How could I do printing like the POS terminal printer?
|
|
|
|
|
When printing, anything rendered to the printer HDC between calls to the StartPage()/EndPage() calls will be printed for that page (as long as its on the actual printable area).
So you would be doing something like:
StartDoc()
while (pages_to_print)
{
StartPage()
while (output_for_this_page)
{
print_a_line
}
EndPage()
}
EndDoc()
If you need to print like a terminal, you need to keep track of the current Y position on the page. After every line printed, you increment y value by the height of the line. When y > pageHeight, you end the current page and start a new one.
StartDoc()
while (pages_to_print)
{
StartPage()
y = 0
while (output_for_this_page)
{
print_a_line at 0,y
y += lineHeight
}
EndPage()
}
EndDoc()
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
But if I do not call EndPage() or EndDoc(),I could not get the line.
I want to see something printed when I print a line. How? Thank u!
|
|
|
|
|
StartDoc / EndDoc - designed to protect multipage documents from interspersed with others. PrintJob is suspended until EndDoc is called.
>How could I do printing like the POS terminal printer?
For remote spoolers - you can not, should not, and will not be allowed to; local - open device e.g. par port/usb and write directly. Even if local with direct write it still likely not work with most modern printers: laser printers, etc ....
Brian
|
|
|
|
|
Hi
I have the following problem:
I have a client where there is defined a network connection (mapping) to another computer. This is active when you double click the drive otherwise you see that red cross in the explorer just below the driveletter.
I have searched the web on how i can automatically restore the connection .. i have come accross the following link:
'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetrestoreconnectionw.asp'
This is about the SDK 'WNetRestoreConnectionW'. There are almost no examples of using this SDK + this SDK won't work on Win95, 98 and Me computers.
Any good way of solving this problem?
Best regards
Jens
|
|
|
|
|
Considering all the desing guidelines of safe programming including exception handling, just wondering do we actually write the handler for each and every possible error/excepion in our code? Its certainly a good practice but how practical it is in terms of LOC that we put for handling the errors which may never occur as well.
Just consider this piece of code
LPTSTR l_strResConn = new TCHAR[NAME_LENGTH];
//check over the value
int l_nRet = LoadString(theApp->m_hInstance,....)
For every loadstring, I should check for the value of l_nRet. But practially in my code, I've just ignored it at every place.
|
|
|
|
|
You should start by writing ony a few than as you go along fixing bugs you end up writing all of 'em
Make ur own judgement and use common sense (but as you know common sense is not so common ! )
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Hi,
I have developed a custom activex control.when i try to register this activex control using the command regsvr32,i get the message "LoadLibrary("mystrings.ocx")failed.The specified module could not be found.
can some one tell me why this message comes and what is the solution for this.This message comes only in few machines.registration is successful in most of the machines.
Thanks in advance
|
|
|
|
|
Does ur OCX have any dependecies that might now be present at some machines ?
if there are you need to copy them as well
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Use Depends.exe that comes with visual studio to check wheather your module is able to get all the dlls that it depends on. i.e ? against a certain dll means that dll is not accessible and hence the registeration is failing.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
I may be stating the obvious, but did you try regsvr32 "C:\YourFullyQualified\PathToOcx\yourocx.ocx" ?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Hi All,
Thanks for your answers.regsvr32 was not able to find one of the dependent modules.I had to copy both to a specific folder and register using absolute path of my ocx file
Thanks once again
Raghu
|
|
|
|
|
Dear all,
In the main application I use CDatabase to connect to SQlServer.After this, I pass the pointer to a variable in a dll using a function.
When I try to use ExecuteSQl or I try to open a CRecordset, the program fail with access violation in release version. If I use the debug version of the main program and the dll everything is fine.
Can you help me please with a solution to this issue?
Thank you very much.
|
|
|
|
|
Are you checking the pointer against NULL before dereferencing it?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Yes, the pointer is null in release version....
I don't have any ideea why...
|
|
|
|