|
Hello everybody !
I don't want to read the Text File,because the file is too large.
example , if the text file only have this characters ,like "12356789".
when I user this C++ code ,it will cover the old data.
<br />
FILE *pFile = fopen("1.txt","w");<br />
fseek(pFile,3,SEEK_SET);<br />
fwrite("4",1,strlen("4"),pFile);<br />
fclose(pFile);<br />
How to insert the character '4' into the text file ?
thanks for your reply !
Best Reguards !
|
|
|
|
|
wangningyu wrote: How to insert the character '4' into the text file ?
Create a temporary file and copy contents of 1.txt into this file up to the insertion point. Insert '4' into temporary file. Copy remainder of 1.txt into temporary file. Close both files. Delete 1.txt. Rename temporary file to 1.txt.
Make sense?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
Hi; I am stumped on what search terms to use to find information on this without getting far far too many 'false positives'.
My application embeds metadata in files that support embedded metadata. For files that DON'T support embedded metadata, I want to create a "sidecar" file.
There is a feature of Internet Explorer that works like this:
When you save a Webpage from Internet Explorer (in certain circumstances, I'm not sure which) it will create a folder with the same name as the file (without the extension of course) and store all the "assets" associated with the page in that folder. If you attempt to delete the folder of assets, it also deletes the .html file that refers to them... and vice versa.
so, there is some kind of hard-wired relationship between the HTML file and the folder full of assets.
I want to be able to make such a connection between a file that has been tagged, and the metadata that is associated with that file, such that if the file is moved, the metadata will be moved along with it, as an artifact of this OS-level "feature".
Perhaps its not an OS level feature on Windows, and some other jiggery-pokery is involved.
But the best I could come up with is to search terms and phrases like
"Webpage, complete" save from Internet Explorer files joined
and in place of "joined" using terms like "linked", "group" etc.
Can someone provide either a suggestion for the exact functionality I am trying to learn about, perhaps a code fragment that can be used to establish such a connection between a datafile and the metadata "sidecar" file?
Thanks in advance
|
|
|
|
|
|
Thanks for the reply... our software does install a shell extension to monitor changes to files, but I think what will need to be done is to change file properties in a manner that the operating system will consider the files "joined" so file move / copy / delete operations work on the files as a set.
I can't find any code examples or documentation on how Windows does this, and / or if it a fundamental part of the OS or if it is an IE "shell extension" (where the OS ends and IE begins is topic for another discussion) or if there is a accessible API for this at all.
That's what I'm asking. If there's an API that is common to all Windows PCs that can be used to "join" files in this manner so all file copy / delete / move operations on one file affect the other file(s) in the set. Part of this problem is that when I attempt to Google it (using terms relevant to the feature as it is implemented in Internet Explorer) i.e. "Webpage, Complete" save files joined Internet Explorer I get so many spammy / false-positive results I can't find what I need.
Thanks in advance for any help!
modified on Tuesday, November 3, 2009 9:19 AM
|
|
|
|
|
I'm guessing that this is an explorer feature.
You should be able to do this using your extension when a delete happens.
|
|
|
|
|
Member 3238438 wrote: so, there is some kind of hard-wired relationship between the HTML file and the folder full of assets.
This is something that can be configured by Windows Explorer. From the "Tools" menu select "Folder Options..." then select the "View" tab. Scroll down to the "Managing pairs of Web pages and folders" setting. There are three options. It sounds like you have "Show both parts but manage them as a single file" selected. (I think this is the default.)
Member 3238438 wrote: Perhaps its not an OS level feature on Windows, and some other jiggery-pokery is involved.
It's jiggery-pokery on the part of Windows Explorer rather than the Windows OS. If you try deleting the html file using the DOS command DEL I think you'll find the like-named directory still in place.
I'm not sure if this will get you closer to your goal, but I hope it helps.
BDF
People don't mind being mean; but they never want to be ridiculous.
-- Moliere
|
|
|
|
|
I'm working on a project inserting one record into sqlserver database with stored process.
The problem is that one of the record value is __int64 type which is adBigInt for ado.
how to do the type casting?
My code is below
_CommandPtr commandPtr;
__int64 value1 = 1234567890123;
int value2 = 1;
CommandPtr->Parameters->GetItem("@BusinBala")->Value = value1; (wrong ,can't casting)
CommandPtr->Parameters->GetItem("@BusinBala")->Value = value2; (ok)
what is the solution?
pls help
|
|
|
|
|
tyr2000 wrote: CommandPtr->Parameters->GetItem("@BusinBala")->Value = value1; (wrong ,can't casting)
I think Value is a VARIANT structure. Does that have a 64-bit member (e.g., llVal )?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
may be VARIANT doesn't have a 64-bit member. what shall I do ?
|
|
|
|
|
If it necessary for you to use 64 bit value then better is store in by converting BSTR.
Величие не Бога может быть недооценена.
|
|
|
|
|
in msdn of vs2005, the _variant_t class has overlapped
variant_t& operator=(
unsigned __int64 ui8Src
);
why i can't use the function?
|
|
|
|
|
Please check the
C:\Program Files\Microsoft Visual Studio\VC98\Include\COMUTIL.H file, and check whether
variant_t& operator=(
unsigned __int64 ui8Src
);
is available in this file.
Величие не Бога может быть недооценена.
|
|
|
|
|
Adam Roderick J 09 wrote: Please check the
C:\Program Files\Microsoft Visual Studio\VC98\Include\COMUTIL.H file...
Isn't that VS6 specific? I would think C:\Program Files\Microsoft Visual Studio 8\VC\include\comutil.h would be more in line with the OP's version.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Yes,
Since am a VC6.0 fan i gave VC6 path reference
so i am changing this
C:\Program Files\Microsoft Visual Studio\VC98\Include\COMUTIL.H
as
..\VC\Include\COMUTIL.H
Величие не Бога может быть недооценена.
modified on Friday, November 6, 2009 7:17 AM
|
|
|
|
|
tyr2000 wrote: may be VARIANT doesn't have a 64-bit member. what shall I do ?
Quit guessing and verify whether it does or doesn't.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I wrote the below function to read the contents of a single line CEdit control when the enter key is pressed.
void CCommandBox::ProcessEnterKey()
{
int dLineLen = LineLength();
char* szCommand = new char[dLineLen()+1];
GetLine(0, szCommand);
szCommand[dLineLen] = '\0';
E.m_pcpCmdParser->ProcessCommand(szCommand, false);
SetWindowText("");
delete[] szCommand;
}
It works perfectly when running in debug mode but when I build a release version szCommand just gets filled with junk. I had this exact same problem last time I tried to do something similar and in end I had to switch to a CRichEdit and use StreamOut() but I'd rather not do that again.
What's the correct way to read a line from a CEdit control so that it works in a release build?
|
|
|
|
|
How about using GetWindowText() .
CString csText;
GetWindowText(csText);
|
|
|
|
|
Thanks a lot for the help. GetWindowText works great in both the debug and release build.
|
|
|
|
|
char* szCommand = new char[dLineLen()+1]; ???
=> char* szCommand = new char[dLineLen+1];
i wonder that the compiler isnt yelling
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have a C++ class that send command to a system
but since the system is not ready to test yet, I wrote a java server socket that listens to the commands that sends from the C++ client to see if the command is correct and also want to check to see if the C++ can receives any response from the server socket ....
I try to print the command while the java socket is reading it....however, I can only see the printout after I stop the client sending commands, it looks liked the C++ flushes the the command out once it is stopped..
the following is the the partial coding of my project that connects to the socket
initializing:
StringHelper temp;
memset ((char *)&serverAddress, 0, sizeof(struct sockaddr_in));
serverEnt = gethostbyname (serverHostName);
if ( serverEnt == NULL )
{
ErrnoMapper enm;
temp = temp + "Unable to find host name: " + serverHostName;
temp = temp + " gethostbyname (): errno=" + errno + " " + enm.mapErrno( errno );
cout << temp << endl;
}
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = ((struct in_addr *)(serverEnt->h_addr))->s_addr;
serverAddress.sin_port = htons(serverPortNumber);
connecting to the host
StringHelper temp;
mySocketFd = socket (AF_INET, SOCK_STREAM, 0);
if ( mySocketFd == -1 )
{
ErrnoMapper enm;
temp = temp + "Unable to create socket to " + serverHostName;
temp = temp + " socket(): errno=" + errno + " " + enm.mapErrno( errno );
cout << temp << endl;
close(mySocketFd);
}
if (connect(mySocketFd, &serverAddress, sizeof(struct sockaddr_in)) == -1)
{
ErrnoMapper enm;
temp = temp + "Unable connect to " + serverHostName + ", port=" + serverPortNumber;
temp = temp + ",connect(),errno=" + errno + " " + enm.mapErrno( errno );
cout << temp << enld;
close(mySocketFd);
return 0;
}
sending command
if ( send(theSocketId, theBuffer, theLength, 0) != theLength)
{
ErrnoMapper enm;
StringHelper temp("Unable to send to ");
temp = temp + serverHostName + ", port number: " + serverPortNumber;
temp = temp + " send() : errno=" + errno + " " + enm.mapErrno( errno );
cout << temp << endl;
}
|
|
|
|
|
Normally a C++ client will do a send immediately.
Why don't you write a simple C++ socket server and check against that.
|
|
|
|
|
do you have an exmple of doing that ??
I am newbie on the socket connection ....
thanks
|
|
|
|
|
You just need to call socket , bind , listen , accept and recv in that order.
|
|
|
|