|
You're asking for write access to a key under HKLM. RegCreateKeyEx() is returning access denied, which means the user doesn't have write privileges to that key. Run your code as a restricted user (not admin) and you'll see the same error.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
#include "witty-quote.h"
|
|
|
|
|
I have a file with a lot of text and I want to find some text and when I do that I need to insert some text at the same line as that text.
Exempel;
bla bla bla
hello
c++ mfc test
ok ok
And if a find hello I need to insert text after hello how do I do that?
Please help me..
|
|
|
|
|
Well, you could read the file in line-by-line and output each line to a temporary file. When you get to the line in question, output the additional text.
If, however, you can read the file in as one big blob, you can use one of the various 'find' functions (e.g., CString::Find() ) to locate the text. Write everything up to that point to a temporary file. Insert the additional text. Write the remainder of the original file to the temporary file.
In either case, when done, close both files, delete the original file, and rename the temporary file.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
So is there not away to just inser the text at that line im at?
|
|
|
|
|
What do you mean by "just?" Wouldn't one or both or my suggestions do what you require?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have a file with text to,
and I want to find text in that file and when I fins that text I need to put in text in the same line as the text I find how can I do that? At the end of that text line.
|
|
|
|
|
You cant just insert text in the middle of a file, unless that file has been padded to receive new text.
What you have to do is rewrite the file completely. You can either:
1) Read the whole file in memory, fiddle with that memory then save back to disk (in same file ?)
2) Read the file chunk by chuck, and write each chunk in a second, temporary, file. After which, you then erase the old file and rename the one you just created.
Hope that helped.
|
|
|
|
|
Hi,
I am working on a MDI application. I derived my own view an document class and called AddDocTemplate with these classes in my CWinApp class. The views and document seem to show up when I go file/new.
But whenever I modify the document and call pDoc->UpdateAllViews(NULL) to make my views reflect the changes, I get an ASSERT failure.
void CWnd::AssertValid() const
{
...............
// should also be in the permanent or temporary handle map
CHandleMap* pMap = afxMapHWND();
ASSERT(pMap != NULL);
...............
//more code
}
Does anyone know what a permanent or temporary handle map is and how I might add one? It doesn't seem like this is in the MSDN documents as there is no reference to afxMapHWND().
Thanks in advance.
|
|
|
|
|
Whatever is causing this is unlikely to be related to permanent vs. temporary handle maps. Normally you don't add windows to handle maps yourself. You need to look at the code that is ASSERT'ing and work back from there.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hello,
I am using the tecnique http://www.lambdasoft.dk/comet/doc/cometautoexp.html
in order to provides custom formatting for variables in the VisualStudio debugger.
I can tell that it works very well.
What puzzles me is this.
In the code I export the function from the DLL in this way:
extern "C" {<br />
__declspec(dllexport) HRESULT WINAPI VCF_DateTimeEvaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved );<br />
}<br />
But then:
dumpbin /exports AutoExp.dll
shows
_VCF_DateTimeEvaluate@28
instead than simply
VCF_DateTimeEvaluate
both by compiling with vc6 and vc70.
Other people swear that I should simply get
VCF_DateTimeEvaluate
as long as I use: extern "C" { ... }
Please note that extern "C" does something anyway, because without it I would get the mangled name:
?VCF_DateTimeEvaluate@@YGJKPAUtagDEBUGHELPER@@HHPADIK@Z
If you have the patience to answer to another related question, here it is !
If I do use a definition file, it works with vc6 by just including it in the project, as I get: VCF_DateTimeEvaluate
But with vc70 it doesn't work. Why ? What should I do different ?
|
|
|
|
|
Did you add an entry to your <project>.def file ?
<br />
DLLEXPORT<br />
<br />
VCF_DateTimeEvaluate PRIVATE<br />
Its probably auto-generating something if you dont have it in the def file.
|
|
|
|
|
Thank you very much.
At least an answer !
But it doesn't work
This is my definition file for vc70:
AutoExp.vcproj, AutoExp.cpp and AutoExp.def are all in the same directory
AutoExp.vcproj has AutoExp.cpp and AutoExp.def in itself.
<br />
<br />
Is there, maybe, some options in the project that creates problems ?<br />
<br />
Cheers,<br />
Marcello
|
|
|
|
|
How does it show in Depends.exe (which comes as a VStudio 6 tool)
How do both VC6 and VC7 dll compare in terms of exports using depends ?
|
|
|
|
|
What a cool program !
I dodn't know about it ! Thank you !
Under Depends it shows exactly as with dumpbin
vc6: it appears as VCF_DateTimeEvaluate
vc70: it appears as _VCF_DateTimeEvaluate@28
|
|
|
|
|
Hmmmmmmmmm ...
Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?
|
|
|
|
|
Thank ou for all the help.
I will try to check what you suggested me tomorrow !
Cheers,
Marcello
|
|
|
|
|
|
Problem solved !
I had the feeling that vc70 was not reading this darn definition file, because by changing it it was not asking to rebuild.
So I looked around and I found the option:
Property Pages > Linker > Input > Module Definition File >
and there I put AutoExp.def
where the content is:
<br />
LIBRARY AutoExpEx<br />
DESCRIPTION "Implements Custom Evaluator for Microsoft Debugger"<br />
EXPORTS<br />
VCF_VariantEvaluate @1<br />
It works !
The linker screams both with the DLLEXPORT declaration and/or I do not use the '@'
Note that the help in VisualStudio says that we should not specify the file in the environment, only to include it into the project !
But it works.
Thanks a lot !
I really appreciated !
|
|
|
|
|
THe docs say:
"WSAEFAULT
10014
Bad address.
The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. "
I get 10014 (WSAEFAULT)from WSAGetLastError()
shm[0][0] = (void*) new char[50000000];
port_data = shm[0][0] ;
if(!port_data)
{
if(fpLog)fprintf(fpLog, "port_data is NULL\n");
}
nread = recv (socket_fd, char*)port_data,2730600 ,0);
}
nread turns out to be -1 (SOCKET_ERROR). The port_data NULL msg doesnt get printed.
I checked that the pointer is not null, and also that the size of the port_data is big enough...the two things that can make recv fail.
What should I look at as a source of this error ?
A note on the structure of the app:
I have the recv in a client loop over a set of files. Each file is opened and read by a server which sends the data to the client (who has the recv). This port_data is used by the client, NOT deleted, and then the pointer is reused for the next file If I run this with one set of files, theres no problem. But with another set, it arrests on the second recv (whatever the order of this different set of files). My server has no problem opening reading and sending the second file.
I break out when the server tells me to:
while (1)
{
recv(port_data..) <------------- one recv for each file send from server
do stuff with port_data
make sure its not NULL at this point
}
I havent changed the size allocated to port_data between recvs so it is always
50000000 I imagine. I dont know how to verify this for sure though.
Thanks,
sb
|
|
|
|
|
I'm trying to build a SDI-application in a dll. The problem is that the application of the exe (which runs and communicates with my dll) catches all messages. Ie if i push Ctrl+P in the dlls Window, the print-dialog of the exe's window shows up. Other messages like ID_INDICATOR_NUM (for updating the NumLock-State in the StatusBar) are also catched by the exe's message map.
In my eyes, the only solution is to create another thread which contains the dlls window, so that it has its own message map. But i did not get that working. Any ideas?
|
|
|
|
|
I'm importing data from a file, each data will have a name, and the name might not be unique, so I need to remove duplicates. the number of data can be huge, in the millions.
the data is inserted in a old C linked list, so I can't really scan the list each time, it will not be very optimal.
I was wondering if using a temporary std::map to insert the names can be an effective way of soing it ? each time I load a data from a file, find it in the map ? is it's there, skip it ... if not, insert it in my "database" and in the map.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
the data is inserted in a old C linked list, so I can't really scan the list each time, it will not be very optimal.
True, but if you used a binary search tree instead, you could get the number of scans down to 20-ish. You could also use a hash table. If the second instance of the item is encountered, it will have a hash value that is already in the table and can thus be skipped.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks David!!!
I need to review my hash table theory !!!
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I also use Ternary Search Trees for similar tasks as yours.
http://www.codeproject.com/csharp/tst.asp
|
|
|
|
|
I have a base interface called IBFace.
From IBFace, I have derived a base implementation class called CBFace.
I then declare a new interface called IBFace2, which derives from IBFace.
And finally, I wish to create a class that uses the base class CBFace implementation, but also derives from IBFace2 to allow me to supply the implementation. Lets call this final class CBFinalFace.
So the inheritance tree looks as follows:
IBFace
- CBFace
---------
- IBFace2 |
-----------> CBFinalFace
When I compile (with all the pure abstract functions implemented), I receive the C4259 warning that "pure virtual function was not defined". The functions it lists are all the functions from IBFace.
How do I get past this? It seems that even though CBFace implements all the functions, the fact that I derive from CBFace and then again from IBFace2 (which also derives from IBFace), I get the problem.
any ideas?
|
|
|
|