|
YusufK wrote: char* cap = _com_util::ConvertBSTRToString(vtProp.bstrVal); //Problem occurs here
Return type of the Speed querry is uint32.
reason for crash is that you are converting the long value to String without proper way!
try to check what VT member contain before proceeding ie.
if(vtProp.vt==VT_BSTR)
char* cap = _com_util::ConvertBSTRToString(vtProp.bstrVal); //Problem occurs here
else
ltoa(vtProp.lVal,cap,10);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Hello,
how to change an content of a file?
Ok, i know how to open and read file for changing, now i need to replace one string with a new value!
For example, if the file have only this one sentence:
"Have a good day"
i like to replace the "good" with "nice"! so that the content is now "Have a nice day"
In my solution i read all file content in an CString, than use CString::Replace(csOldString, csNewString)
and write then complete content to the file back!
I mean that is posible to solve this with better solution, maybe without reading all content!
Is there any way to do this different as im described here or is this the common way for this?
regards
break;
|
|
|
|
|
there's no way to "change" the content of a file.
you have to open it, read it, modify what you want in RAM, overwrite it, and close it...
|
|
|
|
|
Hi,
ok, thanx for Answer, so is my guess right!?
regards
break;
|
|
|
|
|
|
Hello WhiteSky,
thank you, that is what i mean, read file -> get content->modify->write back to file!
regards
break;
-- modified at 7:43 Tuesday 31st October, 2006
|
|
|
|
|
|
Hello WhiteSky,
thank you wery much for ask!
I think yes?!
I read my file and store all data in an CString, than to modify that content
use CString::Replace(LPCTSTR csOldString, LPCTSTR csNewString);
In steps looks like this:
1.) Open File in "r" modus
2.) Store Content in CString
3.) Close File
4.) modify Content
5.) Open the same file in "w+" modus!???
6.) Write content back to file
I use fopen() and fprintf() to read and write!
so that my idea?:->
i mean it does what i need, dont know if its the best way, that is the reason
why i ask im comunity!
with best regards
break;
|
|
|
|
|
I think its good because you dont know where's text that you want to replcase
|
|
|
|
|
You can use variuos seek functions (fseek, ofstream::seekp, ..., depending on API) to set the write pointer position in a file, and then start replacing data inplace. You cannot insert extra bytes however, but you can overwrite existing data.
|
|
|
|
|
Hello,
not need to insert extra bytes, to overwrite existing data is ok, now need to know what when the new data ar larger then the old!?
So i think i use the previous way, i dont need this in an multithread function, i read only one file
one times nad change a part of them, replace the old part with new content!
regards
break;
-- modified at 8:48 Tuesday 31st October, 2006
|
|
|
|
|
I have problem using the function ResUtilStartResourceService(...)
i included the file clusapi.h and the compiler gives me the error "undeclared identifier".
i tried to include the file Resapi.h the compiler gives me the error "unresolved external symbol _ResUtilStartResourceService@8".
Best regards,
Simos
|
|
|
|
|
I figured out the error.
The problem now that the service is installed, but when i call the function ResUtilStartResourceService(...) it returns error code 1060 (service does not exist).
Can any body help with this.
Best regards,
Simos
|
|
|
|
|
Check the name of the service you are passing to the function, is is the correct one ?
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
Yes it is correct.
Regards,
Simos
|
|
|
|
|
Yes it is correct yet it returns the error 1060, any ideas?
Regards,
Simos
|
|
|
|
|
Silly question....
Have you actually installed your service, if so how did you do this ?
It does sound like this hasn't been done, you must install the service correctly first.
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
ResUtilStartResourceService() is defined in "Resapi.h"
You are including the wrong header file, as you can see from the ResUtilStartResourceService() help page in the MSDN (if you'd looked )
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
Hello!
I have a simple question. Let us assume that all my resources are located in the resource-only DLLs. I load DLL, use resources from it, then unload it, load another DLL and use resources from that another DLL. What is bothering me that is: what happened to the memory, allocated to the resources from the first DLL.
For example:
<br />
HMODULE language_DLL_handle = LoadLibraryEx(language_DLL_file_name, NULL, LOAD_LIBRARY_AS_DATAFILE);<br />
HRSRC hrsrcDlg = FindResource(language_DLL_handle, TEXT("MyDialog"), RT_DIALOG);<br />
HGLOBAL hglobalDlg = LoadResource(language_DLL_handle, hrsrcDlg);<br />
LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)LockResource(hglobalDlg);<br />
<br />
DialogBoxIndirect(hInst, pDlgTemplate, NULL, (DLGPROC)DlgFunc);<br />
<br />
FreeLibrary(language_DLL_handle);<br />
language_DLL_handle = LoadLibraryEx(another_language_DLL_file_name, NULL, LOAD_LIBRARY_AS_DATAFILE);<br />
<br />
hrsrcDlg = FindResource(language_DLL_handle, TEXT("MyDialog"), RT_DIALOG);<br />
hglobalDlg = LoadResource(language_DLL_handle, hrsrcDlg);<br />
pDlgTemplate = (LPDLGTEMPLATE)LockResource(hglobalDlg);<br />
Here is the question: what happens to the memory, used by the first dialog template, loaded from the first DLL? Is it leaked? Does that mean that if, for example, I have changed DLLs 1000 times my app will allocate the huge amount of memory which is never freed?
Or that memory is somehow magically freed on the call to FreeLibrary?
PS: There are specialized functions LoadMenu - DestroyMenu, LoadCursor - DestroyCursor and so on. But in my case of the Dialog Template resource there is no such function. So, I am wondering ...
PPS: There is function FreeResource. But it is obsolete and is essentially a nop under Win32.
|
|
|
|
|
|
No. This function (FreeResource) does nothing under Win32. Look at it in debugger:
FreeResource:<br />
77E6D5A2 xor eax,eax <br />
77E6D5A4 ret 4<br />
The answer to my question lies here: Microsoft KB 193678[^]
In particular:
The resource obtained with LoadResource is automatically freed when the module that it was loaded from is unloaded. If the resource is in a .dll, freeing the .dll using FreeLibrary also frees the resource.
It means that under Win32 LoadResource does not allocate any additional memory, so, essentially, FreeLibrary frees resources memory too. So, I don't need do any additional steps to free the memory - all the memory is gone from my address space when DLL is unloaded by FreeLibrary.
|
|
|
|
|
Hi everyone,
in my MDI Project i don't use the Doc/View Architecture.
So i re-use always the ChildWnd & Doc for each View...
I read on the MSDN Site that a Doc/View Architecture is not obligatory.
So i could create a simple CMDIChildWnd and display it ( so i don't need to add Templates )
But in the ON_CREATE i must add all components by programmating.
Is there a solution to associate a Dialog with the ChildWnd ( add controls on the dialog is easiser )
Or is it not possible and i must continue, by creating the Templates with ChildWnd, View and Doc ?
Many Thanks
|
|
|
|
|
One way is to use a modeless dialog as the client window of the MDIChild frame.
In the following example I show handler functions for WM_CREATE and WM_SIZE.
pMyDialogClient is a CMyDialogClient pointer - add this member to your CMyMDIChildWnd class.
int CMyMDIChildWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
pMyDialogClient = new CMyDialogClient();
pMyDialogClient->Create(IDD_MYDIALOG, this);
return 0;
}
void CMyMDIChildWnd::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);
if (pMyDialogClient && IsWindow(*pMyDialogClient))
pMyDialogClient->MoveWindow(0, 0, cx, cy);
}
|
|
|
|
|
Ok i see, it isn't a Frame within a Dialog, but 2 objects, ( the frame and a Dialog )
which are superposed and moves the same way, that the user sees all the time "one" window
Good idea ! Thanks
|
|
|
|
|
baerten wrote: Ok i see, it isn't a Frame within a Dialog, but 2 objects, ( the frame and a Dialog )
which are superposed and moves the same way, that the user sees all the time "one" window
Yes
In MFC they call them frame windows and client windows ("views") because they are in the client
area of the frame. There is code built in to the CFrameWnd class to automagically move/size the
"client window" for you so you could avoid having to do the MoveWindow() yourself, but for dialogs
it takes a little tweaking in the dialog class if I remember right.
Cheers,
Mark
|
|
|
|
|