|
Ok. It makes sense now . You're trying to open a device driver, not a simple DLL like I though you meant. Sorry about that
I haven't actually used had to use OpenDriver() , so I can't help much, but there's nothing that suggests it wouldn't work from inside a DLL. In fact, now I think of it, it should work no problem at all - gdi32.dll must use it to load the display device drivers.
Does the driver you're using actually exist on the computer?
Are you passing the correct registry entry (or DLL file name) as the first parameter?
Are you passing NULL as the second parameter?
Are you passing a valid value for the third parameter? Some drivers may fail to load if this value is incorrect.
That's about all I can think of at the moment
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
yes,i had passed the correct registry entry (or DLL file name) as the first parameter.but why to pass NULL as the
second? In fact ,i only try to rewrite the simple application to a dll.when i step to debug the dll,i found the problem is that OpenDriver() fail ,but i hadn't changed the argument the former application use
a good man in china
|
|
|
|
|
gdzfy wrote:
yes,i had passed the correct registry entry (or DLL file name) as the first parameter.but why to pass NULL as the
second?
The second parameter tells Windows which registry key the registry key in the first parameter is located in. If you pass NULL, is uses the default: Drivers32 . If you pass in the DLL file name for the first parameter, then the second parameter is ignored.
gdzfy wrote:
In fact ,i only try to rewrite the simple application to a dll.when i step to debug the dll,i found the problem is that OpenDriver() fail ,but i hadn't changed the argument the former application use
So the application worked, and you copied the code exactly, but now it doesn't work?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
yes ,the application works well ,but my dll don't.I copy the
code exactly and only change few .
that is this line:
hReelDrv=(HDRVR)OpenDriver(L"reeldrv",L"Drivers32",0L);
another thing:the code file is *.c but i change it to
*.cpp.
thanks a lot!!
a good man in china
|
|
|
|
|
Ok, I can't actually help much more, but couple of things you could try:
Try creating a completely blank Win32 app from scratch (ie. with just a WinMain() function) and add only this line to it. Does it work? If not, then there's something else in the other application that causes it to work.
If it does work, do exactly the same thing but create a blank DLL and add this line in DllMain() and see if it works. If it does, then there's something in your DLL that is causing it not to work.
If the clean app works, but the clean DLL does not, then it doesn't look like your going to have much success, unless there's another API function you have to call first to get drivers to work in DLLs (I don't think there is, but I'm not an expert on drivers)
If the app doesn't work, then look in the sample app for something else that might cause it to work (I have no idea what, but something might).
That's about all I can offer. Perhaps someone else can help more
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
well,thank you very much!
a good man in china
|
|
|
|
|
I am trying to send data between to sockets. Initially I am trying to send an array of short ints (fourteen to be exact) and on the receiving end use another array of short ints to hold the data. Unfortunately this doesn't seem to be working for me. When I use a string for a buffer on the receiving end just to see if anything is coming through I get nothing. Is this attempt of mine futile, and would a struct with fourteen member varialbes be able to fix this problem?
|
|
|
|
|
What is the size of the data received via WSARecv() or recv() in bytes?
Kuphryn
|
|
|
|
|
The received bytes is 28 as is the sent bytes 2*14...yet for some reason, I don't get anything.
|
|
|
|
|
Here are the two functions I have written up for this purpose if it helps:
int ReceiveHeader(SOCKET ClientSock, short iHeader[], int iLength)
{
short iHeaderBuffer[14];
int iReceivedTotal = 0;
int iReceivedThisPass = 0;
int x = 0;
int iThisX;
while (iReceivedTotal < iLength)
{
iThisX = 0;
for (short i = 0; i < (14 - (iReceivedTotal / 2)); i++)
{
iHeader[x] = iHeaderBuffer[i];
x++;
iThisX++;
}
iReceivedThisPass = recv(ClientSock,
szBuffer,
(28 - iReceivedTotal),
0
);
if (iReceivedThisPass != SOCKET_ERROR)
{
if ( 28 % iReceivedThisPass != 0 )
{
iReceivedThisPass = 0;
x -= iThisX;
continue;
}
iReceivedTotal += iReceivedThisPass;
x -= (14 - (iReceivedTotal / 2));
}
else
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
return -1;
}
}
return iReceivedTotal;
}
And this opposite is for sending:
int SendHeader(SOCKET ClientSock, short iHeader[], int iLength)
{
short iHeaderBuffer[14];
int iSentTotal = 0;
int iSentThisPass = 0;
int x = 0;
int iThisX;
while (iSentTotal < iLength)
{
iThisX = 0;
for (short i = 0; i < (14 - iSentTotal); i++)
{
iHeaderBuffer[i] = iHeader[x];
x++;
iThisX++;
}
iSentThisPass = send(ClientSock,
(char*) iHeaderBuffer
(28 - iSentTotal),
0
);
if (iSentThisPass != SOCKET_ERROR)
{
if ( 28 % iSentThisPass != 0 )
{
iSentThisPass = 0;
x -= iThisX;
continue;
}
iSentTotal += iSentThisPass;
x -= (14 - (iSentTotal / 2));
}
else
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
return -1;
}
}
return iSentTotal;
}
|
|
|
|
|
OK, you need to think in bytes, not shorts. You are sending 28 bytes - it doesn't matter if an odd number are sent or received. You just restart from whichever byte you were up to. I assume here that iLength is the number of shorts, not the number of bytes.
Sending
You don't need to cache the data locally. Just send it straight from the input array. Try this:
int SendHeader(SOCKET ClientSock, const short *piHeader, int iLength)
{
int iSentTotal = 0;
int iSentPass = 0;
const int iLengthBytes = iLength*sizeof(short);
const unsigned char *ptr = (const unsigned char*)piHeader;
while(iSentTotal < iLengthBytes)
{
iSentPass = send(ClientSock, ptr, iLengthBytes-iSentTotal, 0);
if(iSentPass != SOCKET_ERROR)
{
iSentTotal += iSentPass;
ptr += iSentPass;
}
else
{
if(WSAGetLastError() != WSAEWOULDBLOCK)
return -1;
}
}
return iSentTotal;
} Receiving
Again, there's no need to make a local copy of the data before transferring it to the array. If you're worried about the contents in case of an error, don't be. If a function returns an error, all output data from it should be considered undefined, unless stated otherwise. I don't think that your code will even compile. Try this:
int ReceiveHeader(SOCKET ClientSock, short *piHeader, int iLength)
{
int iRecvTotal = 0;
int iRecvPass = 0;
const int iLengthBytes = iLength*sizeof(short);
unsigned char *ptr = (const unsigned short*)piHeader;
while(iRecvTotal < iLengthBytes)
{
iRecvPass = recv(ClientSock, ptr, iLengthBytes-iRecvTotal, 0);
if(iRecvPass != SOCKET_ERROR)
{
iRecvTotal += iRecvPass;
ptr += iRecvPass;
}
else
{
if(WSAGetLastError() != WSAEWOULDBLOCK)
return -1;
}
}
return iRecvTotal;
} Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
If you are sending as raw values, then a value of 0 would be seen as a terminator for the string.
Elaine
The tigress is here
|
|
|
|
|
Does anyone know if there is a way to programmitically burn a CD from a Visual C++ application running under Windows XP?
I have checked with Roxio and they don't expose their burning engine to programs.
Martin
|
|
|
|
|
|
There sure is, it's called IMAPI and is fully documented in MSDN.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Maunder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I have successfully used IMAPI to burn CDs on Windows XP, however, I can't seem to get around the 31 character filename limit. Any suggestions?
|
|
|
|
|
Yep, check out IMAPI in MSDN.
[edit] Darn it! Should have checked Michael's message first! [/edit]
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi!
I need to know how many lines there are in a text file.
I open the file with fstream... Is there any function or anything that will help me to count the lines?
Thank you very much for your future answers!
Well... I am a beginner ...
|
|
|
|
|
One way is to read through the file and count all occurrences or \r\n.
|
|
|
|
|
If you can use the C routines then you can use standard I/O (stdio.h).
fopen() [open file]
fgets() [reads a single line from file]
fclose() [close file]
Just put fgets() in a loop and as long as there is no error keep reading one line at a time, while incrementing the counter.
INTP
|
|
|
|
|
You could do something like this if you have to:
#include <fstream.h>
void main()
{
fstream infile;
char c;
int i = 0;
infile.open("data.txt", ios::in);
while(!infile.eof())
{
infile.get(c);
if(c == '\n')
i++;
}
i++;
cout << "data.txt has " << i << " lines.\n";
}
-Nick Parker
|
|
|
|
|
Or alternatively:
ifstream File;
File.open("data.txt");
int i = 0;
while ( !File.eof() )
{
File.getline(szBuffer, sizeof(szBuffer), '\n');
i++;
}
cout << "data.txt has" << i << " lines." << endl;
|
|
|
|
|
I've added a CGridCtrl to my dialog in the SDI project just like in the tutorial. I provided the name MFCGridCtrl, just like in the tutorial. However, when I go to create a member variable so I can use it, the Class Wizard won't allow me to add a member variable. Did I miss a step??
|
|
|
|
|
I think you have to do that manually...
[EDIT]
Add this to your class definition:
CGridCtrl m_Grid;
Add this after CDialog::DoDataExchange(pDX); in your DoDataExchange(CDataExchange* pDX) member function
DDX_GridControl(pDX, IDC_GRID, m_Grid);
[/EDIT]
John
|
|
|
|
|
Thanks, I tried that. I copied it from the demo project. I didn't think you could do that.
|
|
|
|