|
Hello
I need your help, to read The source(tags) file of document HTML with visual c++.
Marco Javier
|
|
|
|
|
Are you referring to file editing or socket programming?
Kuphryn
|
|
|
|
|
i need to do a program wich modifies a winXP registry entry and XP security won't let me.
My code will read a registry a key , save it, and make a different key where to load the saved key. The RegLoadKey function call fails with error acces denied. I did set the "SeBackupPrivilege" and "SeRestorePrivilege" so the calling process should have all the security acces needed and the file is ok. But it still doesn't work.
Can you tell me what flag do i need to set in the acces token so i can load/save registry keys? MSDN says it's SE_BACKUP_NAME but it's not enough.
Could the error be in the file security descriptor? I would be strange since the file is created by RegSaveKey.
The MSDN link for Registry functions is
windows Development -> Windows base Services -> Windows System Information ->
SDK Doc -> Registry
Any ideas , suggestions to what it could be?
Thanks
|
|
|
|
|
Hello Everybody,
I have created an AVI Player using DirectShow. This player is working fine. I have also created a View Window (with class name CViewWnd) using CFrameWnd class. This view
window is used in an application which plays its own customised files (of some other extensions) on this view window. Now:
1. I have to play the AVI file on this view window (i.e. integrate my AVIPlayer as a plugin to the original application). To achieve this I am passing CViewWnd instance to AVIPlayer (so
that I will get the cordinates and size of original view window and my AVI player window will overlap the view window. AVI window will be of same size and dimension as of view
window). But it gives error (read point 2 below).
2. Can I pass the instance of my View Window class in AVI Player. If so how? Here condition is that AVI player needs to be a seperate entity i.e. it does not understand my view
window class, neither I can include the view window header in AVI player. If I pass view window as parameter to my AVIPlayer (as HWND *CViewWnd), it gives following error:
((Can not convert parameter from 'class CViewWnd' to 'struct HWND'. Types pointed are unrelated. Conversion requires reinterpret_cast, C-style cast or function-style cats.))
Pls tell me, how my AVIPlayer can understand this CViewWnd class.
Following statement in my AVIPlayer uses the CViewWnd:
pVideoWindow->put_Owner((OAHWND)pViewWnd);
Here 'pVideoWindow' is DirectShow interface and 'pViewWnd' is CViewWnd instance.
1. My original application AVI Player as AVIPlayer is a plugin to the application. So original application does not understand DirectShow.
2. AVI Player does not understand my original application.
So we have to use some MFC standard data type to be passed into my AVI Player.
Thanx in advance for the help.
Regards,
Saurabh Agarwal,
New Delhi, India
(saurabha@momentum-tech.com)
|
|
|
|
|
hey cpians
i need some suggestions / tips on diagnosing a problem w/ one of my
programs / operating environment...
Heres is the data i have to go by so far.
I have a c++ program , which loops forever.
It looks in a particular folder every 30 seconds looking for new files,
that it reads what its found, and processes the info for my needs, than deletes the file.
The program is running on a windows 2000 box.
The problem I am having is that the process just disappears on heavy usage.
No errors , or exceptions that I could try to throw for further data collection, the programs process just disappears and the program stops running and nothing is mentioned of it to me from windows.
Just dont know really where to start diagnosing / building diagnostic data.
Sometimes it will run fine for 2 days looping the same code 20,000 times, and sometimes it dies after 2 hours.
Its the same code looping over and over, so in theory it would be more of a circumstancial / environmental problem the program is running into, than a code itself problem.
any tips / suggestions on places to collect more diagnostic data , or other things to check would be highly appreciated
thanks,
josh
todo....
:: insert inpirational text here ::
|
|
|
|
|
jDawwg wrote:
The problem I am having is that the process just disappears on heavy usage.
Maybe it is just gone fetching a beer, as everybody is busy and noone is looking its way?
Seriously, does it still appear in the task manager? Is it a service?
How do you wait this 30 seconds?
Simply have it touch some file somewhere in every iteration, so you can at least see on the access time when your process has died.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I'm using Sleep() to make it wait. I used the term '30 seconds' loosely before, as you can see in my code posted below I dont quite wait that long even
It doesnt still appear in task manager, it just disappears from everywhere nice and sneaky and strange like! Its not a service.
I know I could build data by coding some logging / RT- data analysis into the program , and then use process of elimination to narraw the problem down between the program or o/s / environment conditions, which I guess seems to be one of my few remaining options so I may bite the bullet and do it this way, i was just hoping i was doing it the hard way or something
#include "stdafx.h"
#include "FileInfo.h"
#include <iostream.h>
#include <fstream.h>
int __cdecl main(int argc, char* argv[])
{
CString s;
char c1[6000]; // Text
char c2[255]; // Storage
char cSpoolFile[300];
char cOutFile[300];
char cOutFileTwo[300];
char cIgnoreList[21000];
char testhold[21000];
char c4[]="blah\0"; // key
int len; //
int result;
int numread;
int sorted = 0;
FILE *input;
fstream outfile;
// read in configuration
ifstream inStream("config.txt");
inStream.getline(cSpoolFile, 300, '\n');
inStream.getline(cOutFile, 300, '\n');
inStream.getline(cOutFileTwo, 300, '\n');
inStream.close();
// read ignore
ifstream inStreamtwo("ignore.txt");
while (!inStreamtwo.eof()) {
inStreamtwo.getline(testhold, 21000, '\n');
s += testhold;
if (!inStreamtwo.eof()) { s += "|"; }
}
inStreamtwo.close();
// null terminate
s += "\0";
// make string to char for var passed into .dll
strcpy(cIgnoreList, s);
// notification...
printf ("Starting Loop.....\n\n");
// loop forever here
while (1) {
// Open directory for read
CFileInfoArray fia;
fia.AddDir(
cSpoolFile, // Directory
"*.*", // Filemask (all files)
FALSE, // Recurse subdirs
CFileInfoArray::AP_SORTBYNAME | CFileInfoArray::AP_SORTASCENDING, // Sort by name and ascending
FALSE // Do not add array entries for directories (only for files)
);
/// here will start the directory iteration
for (int ji=0;ji<fia.GetSize();ji++) {
// read file
if ( (input = fopen( fia[ji].GetFilePath(), "r" ) ) == NULL )
{
//printf( "Could not open file.......%s\n", fia[ji].GetFilePath() );
return 0;
}
// read input , set numread to amount read
numread = fread( c1, sizeof( char ), sizeof(c1), input );
c1[++numread] = '\0'; // null terminate
fclose( input );
// Call the external function with some parameters
result = EXTERNALFUNCTION( *c1, *c2, len, *cIgnoreList, *c4 );
sorted++; // increment the proccessed files count
// act on type returned
switch( result )
{
case PARAM_ONE:
// Open the output file
outfile.open(cOutFile, ios::app);
outfile << c2 << endl;
outfile.close();
break;
case PARAM_TWO:
outfile.open(cOutFileTwo, ios::app);
outfile << c2 << endl;
outfile.close();
break;
default:;
//printf( "Unknown return value\n" );
}
// clear status screen
printf("%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8);
printf(" ");
printf("%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8);
// refresh status
printf("%d", sorted);
// remove file
unlink (fia[ji].GetFilePath());
}
// wait before loop
Sleep(1000);
}
return 0;
}
todo....
:: insert inpirational text here ::
|
|
|
|
|
2 possible cases:
1. As I understand you have 2 processes accessing the files: first process writes the file and your program reads the file -- therefore: You maybe failing here:
if ( (input = fopen( fia[ji].GetFilePath(), "r" ) ) == NULL ) <br />
{<br />
return 0;<br />
}
Because, you return ==> your process exits;
2. Your char c1[6000]; // Text is declared as 6000 bytes long. Therefore, in the following statements:
numread = fread( c1, sizeof( char ), sizeof(c1), input );<br />
c1[++numread] = '\0';
You maybe getting Buffer overrun if file size is larger then 6000 bytes.
I
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
the upper is exactly what it was
todo....
:: insert inpirational text here ::
|
|
|
|
|
This is a design flaw. Instead of wasting CPU cycles polling a folder, let the OS notify you when something has changed. Use FindFirstChangeNotification() or ReadDirectoryChangesW() instead.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
actually, the way it works in production here, we get 100's of small txt files added to the folder every few seconds.
so it really is never polling the folder.
by the time it finishes processing files, than goes through its wait state, their is gauranteed to be more files there for it to find on the need look
thanks tho, but your suggestion is probably not relevant to what causes my current program to crash.
todo....
:: insert inpirational text here ::
|
|
|
|
|
"we get 100's of small txt files added to the folder every few seconds."
Hmm... I think maybe you should reconsider your whole design for this application, creating/deleting hundreds of small files every few seconds is a bad move, it fragments your hard drive and slows down your system performance.
What are you using those small files for? Lemme guess... communicate among processes, am I right? I think you may want to check out some IPC technique, there are many articles about IPC on code project.
|
|
|
|
|
nope, they are not for communication among processes.
really cant disclose details about it, but they are created this way by a program i cannot replace(without massive time /$$, upper management would rather have my time somewhere else ).
so basically , i have to engage the tiny files.
I know about the fragmentation situation, my trusty admins have already configured the specifically for this kind of usage.
if u read the other threads too, the problem with my current solution are solved.
it'd be nice if I had time and money to sit and code redundant solutions to programs i just didnt like the implementation of (there again, anything can be improved upon thought), but this wouldnt make me a productive career programmer , I would be more of an unemployed artist type.
todo....
:: insert inpirational text here ::
|
|
|
|
|
I would think if there are no exceptions or errors when the program disappears, it must have terminated properly. Or, if it is a console app, you might need to run it from the console to see the errors when the program terminates. I suggest you have the program produce a very detailed log of its activities in a file somewhere. This data should get you started.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
yup, data data data ...
i think its time for me to just suck it up and put in some RT logs
thanks.
todo....
:: insert inpirational text here ::
|
|
|
|
|
ahhh!! you got me thinking, and I got less lazy, and did some looking into the way the admins were running the program (which i should care, but usually to busy to care about)
they run a mover script (batch file) to move the neccesary files from one folder, to 2 seperate locations.
Then they run 2 copies of my app , on the 2 seperate folders.
So in those off instances that a copy of my program was trying to access the same files that were still being manipulated by the mover program, i was getting NULL returns on my file open. which , i was doing a natural exit in that case.
I modified the program to not exit if it recieves NULL, and to just be patient and retry to go about its business w/ the next file and no more disappearing app!
thanks for the time / brain power, everyone
we have solved 'the case of the disappearing app'..
todo....
:: insert inpirational text here ::
|
|
|
|
|
In case you cannot (don't have time to) fix the problem, you can use XYNTService[^] to run your program, which will check your program automatically and restart it if neccesary (You need to set CheckProcess to 5 and set Restart to Yes in the XYNTService.ini file to have it check your program every 5 minutes).
Good luck.
[Edit] If you haven't had any idea what a service is about, may be you don't want to waste time on my suggestion. Not all programs are sutible to run from a service. [/Edit]
My articles and software tools
|
|
|
|
|
I need to graphically represent dynamically changing physical grid (300x300) on maximal logical display coordinates, which is usually much larger (~600x600 and more). To avoid blinking, I, first, create Bitmap (according to the grid size) in the memory and thus, using BitBlt, extend it graphically to maximal display size. My problem is that such extension makes Bitmap quality unacceptable. However, using physical grid with the same size (or more) as the display projected, doesn’t reduce the quality.
Enclosed below please find the code.
void CRecDrawView::OnDraw(CDC* pDC)
{
CRect rect ;
int X, X1, Y, Y1, MatrixPart, DrawPart;
COLORREF color = RGB( 128, 128, 0 );
GetClientRect(rect );
int oldBkMode = pDC->SetBkMode(TRANSPARENT);
DrawPart = (rect.Width( ) < rect.Height( ) )
? rect.Width( ) : rect.Height( ) ;
if(DrawPart > MaxCoordinate) DrawPart = MaxCoordinate;
MatrixPart = MaxCoordinate/DrawPart ; // part of matrix, which must be displayed
X = 0 ;
X1 = X + DrawPart;
Y = 0 ;
Y1 = Y + DrawPart;
CDC memdc, * myDC;
pDC->SetMapMode(MM_ISOTROPIC);
SetWindowExtEx(*pDC,DrawPart,DrawPart,NULL);
SetViewportExtEx(*pDC,rect.right, -rect.bottom,NULL);
SetViewportOrgEx(*pDC,0,rect.bottom,NULL);
CBitmap bmp, *poldbmp;
memdc.CreateCompatibleDC( pDC);
bmp.CreateCompatibleBitmap (pDC, DrawPart, DrawPart);
poldbmp = memdc.SelectObject( &bmp );
memdc.BitBlt( 0,0,DrawPart, DrawPart,&memdc, 0, 0, WHITENESS );
myDC = &memdc;
...
}
I’ll be much appreciated for any kind of help.
German
|
|
|
|
|
I need to be able to create some number of checkboxes, this number depends on the number of items that the user previously selected. What I have done is created a loop for the number of selected items, and in the loop I:
for(x = 0; x < numberSelected; x++)
{
CButton button;
CRect rect;
CString buttonText;
GetClientRect(rect);
ClientToScreen(rect);
buttonText.Format("%d", x);
button.Create(buttonText, WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, rect , this, x);
}
UpdateData(false);
Now, I know that *if* this were to work, they would all show up in the same spot because the rect structure never changes, but I just wanted to make sure it would work in a loop like this before I went too far into it. But, this doesn't work anyway, can anyone help me out?
Thanks.
|
|
|
|
|
one more thing, that for loop is inside my OnInitDialog function.
|
|
|
|
|
One thing that might cause problems is that you are defining a single CButton object - and then trying to call it's Create() member over and over again.
You might want to create an array of buttons as a member variable for that dialog box (if you know the maximum number you might possibly have - say 117 if you were doing chemical elements) and then make visible the ones you need visible and use MoveWindow() to position them.
|
|
|
|
|
Once the for loop goes out of scope, the CButton object ceases to exist. Try this:
CButton *pButton;
for (...)
{
pButton = new CButton;
pButton->Create(...);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi all,
i want to do some action when user selects some text in my text box which is an AutoRichEditCtrl. i dont want any button clicks after selection to perform that action. Instead on selecting the text,automatically the corresponding action has to take place.how do i do that???
can anyone please help me.......
Thanks!
ramya.
|
|
|
|
|
I would think you'd want to respond to the WM_LBUTTONUP message.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
If a AutoRichEditCtrl is derived from CRichEditCtrl , you can handle the EN_SELCHANGE notification:
MSDN says:An application can detect when the current selection changes by processing the EN_SELCHANGE notification message. The notification message specifies a SELCHANGE structure containing information about the new selection.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|