|
Windows timer resuloution is about 10 ms, so if you want a timer at 20 you can do ith with the windows timer.
Less than this you have to go to specific HW, or, on later windows OSs, apparently you can change the timer, but it is apparently illadvised.
So yes, your solution will incur a performance hit because of the kernel to user transition.
I took over a sw and driver design once that wrote data byte by byte to a RAM pack. It took 30 seconds to fill the thing with data.
I changed it to writing 2 k packets at a time. It too 250 ms to fill it with data.
Thats the cost of switching form user to kernel to user every byte, as oposed to evert 2k bytes. Heavy eh?
==============================
Nothing to say.
|
|
|
|
|
Fine that you got it to work using the message mechanism and posting the solution.
|
|
|
|
|
enhzflep wrote: In fact, one of the very reasons I avoided coding windows programs for quite a while was the fact that it was considerably more difficult to write code that would interact with hardware directly.
Chieken! Working in the Kernel is SoOoOoO much fun! (Been doing it for 15 years or so)
==============================
Nothing to say.
|
|
|
|
|
Yeah, it is isn't it?
I've had a play with the DDK. Written a couple of trivial drivers and had a toy with the concepts behind root-kits.
I was scared before, but not anymore!
|
|
|
|
|
In a callback, you can pass a static member function, and use a class pointer as the first parameter.
When you register the callback, pass it the address of the static function and for the void * data member, pass the address of the object.
class CTest1
{
public:
static void _DigitalInt(void * pData);
public:
void DigitalInt(void);
};
void CTest1::_DigitalInt(void * pData)
{
((CTest1 *) pData)->DigitalInt();
}
void CTest1::DigitalInt(void)
{
}
|
|
|
|
|
I am creating a view in the dialog.
when i am instantiating the dialog like this
CMyDialog dlg(NULL, L"filename.txt");
dlg.DoModal();
CMyDialog constructor I overloaded so that it takes a file name.
Now in the OnInitDialog() function I an intializing the view pointer m_pView and creating the view, toolbar , everything.
Can I use this m_pView in the constructor of the CMyDialog so that I want to call one function from the CMyView class which takes the filename (filename.txt) as the argument.
check the code of the CMyDialog constructor and OnInitDialog
[code]
CMyDialog::CMyDialog(CWnd* pParent /*=NULL*/, CString filename)
: CDialog(CDlgsViewDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
if(!filename.IsEmpty()) {
m_pView->loadProfile(filename);
}
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_pView = new CMyView();
ShowWindow(SW_SHOWMAXIMIZED);
CRect clientRect;
GetClientRect(&clientRect);
clientRect.DeflateRect(10, 30);
if(! m_pView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, clientRect,
this, WM_USER))
{
MessageBox(L"Failed to create view");
}
}
[/code]
Is this code correct, m_pView will initialized before the constructor called right ? Can access m_pView in the constructor and call the function loadprofile() function which takes the file name.
I am calling this dialog in an extern C fucntion for dll
[code]
extern "C" BOOL __declspec(dllexport)runAppli(CString fileName)
{
CDlgsViewDlg dlg(NULL, fileName);
dlg.DoModal();
return true;
}
[/code]
I am getting error please help me whats going wrong in this ...Thanks a lot for any help.
|
|
|
|
|
sujandasmahapatra wrote: Is this code correct, m_pView will initialized before the constructor called right ?
Nope. Dialog contructor is called before OnInitDialog method.
Veni, vidi, vici.
|
|
|
|
|
ok thanks for your help i am trying to correct it. in case i need help again i'll post it on the same thread. thanks a lot.
|
|
|
|
|
You are welcome.
Veni, vidi, vici.
|
|
|
|
|
Hi,
Is there a built-in string function to insert a # to all the lines which starts with string READ and ends with .(period)
Eg:abc.txt
asadf
sdf
READ abc asdj ads
asdkl asdj
djshf .
EOF
followed by substituion of a string..
Thanks in advance
|
|
|
|
|
try to use CStdioFile::ReadString to read one line once.
|
|
|
|
|
Need to code it in C
|
|
|
|
|
So what do you have so far? You'll find far more people willing to critique existing code than those willing to do your work outright for you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I shall henceforth post the code instantly while asking a new question next time
BTW here is my code and I think am lost...
#include <stdio.h>
#include <string.h>
#define MAX_LEN_SINGLE_LINE 120
#define bufsize 1024
int main()
{
char fileOrig[32] = "test.txt";
char fileRepl[32] = "myReplacedFile.txt";
const char text2find[80] = " READ ";
const char text2repl[80] = "# READ ";
int c, line=0;
char buffer[MAX_LEN_SINGLE_LINE+2];
char *buff_ptr, *find_ptr, *tok;
FILE *fp1, *fp2;
size_t find_len = strlen(text2find);
fp1 = fopen(fileOrig,"r+");
fp2 = fopen(fileRepl,"w+");
int i;
while(fgets(buffer,MAX_LEN_SINGLE_LINE+2,fp1))
{
buff_ptr = buffer;
while ((find_ptr = strstr(buff_ptr,text2find)))
{
while ((c = fgetc(fp1)) == '.')
{
if (c == '\n')
fputc("#",fp2);
else ;
}
while(buff_ptr < find_ptr)
fputc((int)*buff_ptr++,fp2);
fputs(text2repl,fp2);
buff_ptr += find_len;
}
fputs(buff_ptr,fp2);
}
fclose(fp2);
fclose(fp1);
return 0;
}
Thanks in advance,
Faez
modified 1-Mar-12 6:56am.
|
|
|
|
|
How about something a tad smaller, like:
BOOL bPrefix = FALSE;
while(fgets(buffer, sizeof(buffer), fp1))
{
if (strncmp(buffer, "READ", 4) == 0)
bPrefix = TRUE;
else if (buffer[strlen(buffer) - 1] == '.')
bPrefix = FALSE;
if (bPrefix)
fputc('#', fp2);
fputs(buffer, fp2);
} I've not tested it, but hopefully you get the idea.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
There are no changes in the new file at all
Also, there are multiple instance of READ such as END-READ etc whose line should not be precceded with #
I aint understanding how the current file pointer can be incremented till a "\n" or "."
|
|
|
|
|
Faez Shingeri wrote: There are no changes in the new file at all
Use the debugger to step through the code line by line to see what is happening along the way.
Faez Shingeri wrote: Also, there are multiple instance of READ such as END-READ etc whose line should not be precceded with #
The code snippet I provided only precedes those lines that start with READ.
Faez Shingeri wrote: I aint understanding how the current file pointer can be incremented till a "\n" or "."
fgets() internally increments the file pointer.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Nothing helped... Tried alot of trial and error but the o/p refuses to roll out as expected..
|
|
|
|
|
It's working great now .. Thnx alot for help
|
|
|
|
|
So what did you end up with (to get it all going)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
while(fgets(buffer,MAX_LEN_SINGLE_LINE+2,fp1))
{
buff_ptr = buffer;
strcpy(buffer2,buffer);
i = 0;
while( i++ < strlen(buffer))
{
if(isspace(buffer[i]))
continue;
strcpy(buffer2,&(buffer[i]));
break;
}
if(strncmp(buffer2,"READ",4) == 0)
{
found = true;
sprintf(buffer1,"# %s",buffer);
fputs(buffer1,fp2);
}
else if(found == false)
{
fputs(buffer,fp2);
}
else
{
sprintf(buffer1,"# %s",buffer);
fputs(buffer1,fp2);
if(strstr(buffer,".") != NULL)
found = false;
}
}
Alot of thanks to Chandrakantt also in helping me in this one..
|
|
|
|
|
No, there isn't. However it should be relatively simple to implement yourself.
Veni, vidi, vici.
|
|
|
|
|
Dear all
I want to impllement a uniform raycasting in a selected sphere region of a volume and want to calculate the intensity of each voxel that is traversed by a ray, I want to program in open gl,
can any one help me how I can do it?
any help from you appreciate alot.
Best
|
|
|
|
|
Can use DeviceIoControl for retriving data about an USB storage device (flash or hard drive) like: manufacturer, type, revision?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Hi,
For retrieving the manufacturer, type and revision... you can probably use the IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION and populate a USB_DEVICE_DESCRIPTOR struct.
Best Wishes,
-David Delaune
|
|
|
|