|
Assuming the bytes are in the right order, use CreateFile() to create/open the file, and use WriteFile() to write to the file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all my friendz,
i'm developing an application to check multiple mail accounts. I use Iwebbrowser2...and so IE to browse mails.
Now I'm considering a problem. Suppose a person who uses my tool has an instance of IE open...and suppose he has just controlled his mail(without logging out)...my tool starts its check but goes directly inside the account(does not find login page)...and so the tool does'nt find the page it expect to find and fails.
Even if i delete the cookie associated to that account before running the check, if another IE browser instance is open the information remains! (i think in index.dat).
So there is some way to go in any case at login page, without considering the informations in index.dat or cookies???...
please help (
|
|
|
|
|
I am opening a file in readwrite and shareexclusive mode, but later want to change this to different access and share modes, but can't figure out how to do it. I tried using SetStatus but it doesn't seem to work (I think I don't know how to set the m_attributes correctly)... I am currently closing the file and reopening it, which feels like a cludge to me! Any suggestions?
First time opening file:
CFile writeFile;
writeFile.Open(curFile, CFile::modeCreate | CFile::modeReadWrite | CFile::shareExclusive, &fileException)
Then I close and reopen:
writeFile.Close();
writeFile.Open(curFile, CFile::modeRead | CFile::shareDenyWrite, &fileException);
The SetStatus code that is NOT working is:
CFileStatus status;
writeFile.GetStatus( status );
status.m_attribute = status.m_attribute | writeFile.readOnly;
writeFile.SetStatus( curFile, status );
Thanks in advance!
|
|
|
|
|
The open flags are not the same as the file status flags.
Try ReOpenFile() on the m_hFile member of the CFile instead of closing and reopening.
Never mind ReOpenFile() is Server 2003 or better
Mark
|
|
|
|
|
Hey thanks! Do I still need to close the file first?
|
|
|
|
|
>>Do I still need to close the file first?
Looks like it, unfortunately. Even ReOpenFile won't let you change the sharing mode without
closing the handle first. At least that's what I gathered from the SDK.
I'd say closing and reopening is the only way to go ... I may be wrong
Mark
|
|
|
|
|
Need to know if I can directly access elements in an STL array based on the Iterator ..
As for eg
List contains { 1,2,3,4,5,6,7,8 }
if List::Iterator iter = List.begin()
Now to access nth element can the routine be like
int GetElementAt( int index)
{
// range check
iter = List.begin();
iter+=index;
return *iter ;
}
Engineering is the effort !
|
|
|
|
|
act_x wrote: Engineering is the effort !
what happened when you tried it?
cje
|
|
|
|
|
A std::list isn't an "array" and list iterators don't support random access. Vector and deque iterators support the += operator.
|
|
|
|
|
act_x wrote: iter+=index;
try
std::advance(iter, index);
Might work
|
|
|
|
|
will
for(int i=0;i<index;i++,iter++) ;
this="" should="" work="" as="" the="" ++="" operator="" is="" supported="" for="" iterator="" ?=""
=""
<div="" class="ForumSig">Engineering is the effort !
|
|
|
|
|
yes the ++ operator should be supported for the iterator
I sugest you look at the doco
|
|
|
|
|
I created a SDI application which is containing tree control displaying FOlders and files of a System.Now i want ot add functionality drag and drop from GUI to Explorer and Explorer to GUI.When i dragged from explorer to tree, the dragged files and folders to be added where i droped(for ex: if i dropped on USB drive the respected files and folders added to USB drive)
Any ideas?
|
|
|
|
|
See DragAcceptFiles(), WM_DROPFILES, DragQueryFile(), DragFinish(), etc.
Mark
|
|
|
|
|
My tree controlis accepting files after dropping the files how can i handle it?
Meand how can i copied the dropped files to respected folder or drive
|
|
|
|
|
Im not sure do you need to DragQueryFile ?
|
|
|
|
|
Hi fellows. I created an app that have 2 menus. The code for these menus are below:
<br />
hMenu1 = CreateMenu();<br />
hMenu2 = CreateMenu();<br />
hSubMenu1 = CreateMenu();<br />
hSubMenu2 = CreateMenu();<br />
unsigned int uiParams[5];<br />
unsigned int uiNums[5];<br />
unsigned int uiSize = 5;<br />
char cNames[][256] = {"&Menu", "&Estudo Anatômico", "M&odelo com Transparência", "", "&Sair"};<br />
uiParams[0] = MF_STRING|MF_POPUP;<br />
uiParams[1] = uiParams[2] = uiParams[4] = MF_STRING;<br />
uiParams[3] = MF_SEPARATOR;<br />
uiNums[0] = 0; uiNums[1] = 1; uiNums[2] = 2; uiNums[3] = 3; uiNums[4] = 4;<br />
MenuCreator(hMenu1, hSubMenu1, uiParams, uiNums, cNames, uiSize);<br />
SetMenu(hwnd, hMenu1);<br />
DrawMenuBar(hwnd);<br />
char cNames2[][256] = {"&Controles", "&Habilitar/Desabilitar Controles"};<br />
uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = MF_STRING;<br />
uiNums[0] = 5; uiNums[1] = 6;<br />
uiSize = 2;<br />
MenuCreator(hMenu2, hSubMenu2, uiParams, uiNums, cNames2, uiSize);<br />
SetMenu(hwnd, hMenu2);<br />
I have a function that create menus dynamically. Here it is:
<br />
void MenuCreator(HMENU hParentMenu, HMENU hChildMenu, unsigned int uiBehaviors[], unsigned int uiIDItems[], char cNameItems[][256], unsigned int uiSize)<br />
{<br />
if(hParentMenu == NULL || (hParentMenu == NULL && hChildMenu != NULL))<br />
{<br />
MessageBox(NULL, "Menu pai não pode ser nulo", "Erro", MB_OK|MB_ICONERROR);<br />
return;<br />
}<br />
if(hParentMenu != NULL && hChildMenu != NULL)<br />
{<br />
for(int i = 1 ; i < uiSize ; i++)AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]);<br />
AppendMenu(hParentMenu, uiBehaviors[0], (unsigned int)hChildMenu, cNameItems[0]);<br />
return;<br />
}<br />
if(hParentMenu != NULL && hChildMenu == NULL)<br />
{<br />
for(int i = 0 ; i < uiSize ; i++)<br />
{<br />
AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]);<br />
}<br />
return;<br />
}<br />
}<br />
when I insert the first menu, works fine. When I insert the other, the first menu isn't there, just the second. What I want to do is to have 2 or more menus at the same time, like File|Edit|View.
What's going on? Thanks
|
|
|
|
|
Problem solved, I was create 2 main menus. So, when I insert the other main menu it was overlapping the other. I deleted the other main menu and add the items in only 1 main menu
|
|
|
|
|
The application must call the "DrawMenuBar" function whenever a menu changes, whether or not the menu is in a displayed window.
|
|
|
|
|
Hi I have a CSV (Comma Separated Value) file that I need to read in and put data into structures. I am going to be using MFC to have a gui to select a file and read it. I'm more interested in getting to open a csv file and parsing the data. Each like in the csv file will have around 10 items or so....
I just would like to know the syntax of how to go about doing this...
Any help would be greatly apperciated....
Thanks,
C++/MFC; Visual Studio 6.0
|
|
|
|
|
arunkk1 wrote: CSV (Comma Separated Value) file that I need to read in
Read the file line by line.
Then, on each line, unleash a tokenizer: The boost one[^]comes to mind.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
UNLEASH THE TOKENIZER!!!
Aye, Captain!
Unleashing the tokenizer!
|
|
|
|
|
Mark Salsbery wrote: Aye, Captain!
Unleashing the tokenizer!
Hmm - so my intended joke did not come through.
I always thought "unleash" has a meaning along the lines of "let loose onto", "expose someone to it".
Instead, it seems to be sailor-slag for "untie a rope"
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
No No... the joke DID come through. I actually sprayed coffee on my moniter when I read it haha.
I liked it! I just took it even further.
Mark
|
|
|
|
|
For each line read from the file, you can use AfxExtractSubString() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|