|
To add to Hans Dietrich's reply...
Serialization works good for this IMO.
You could make the class(struct) serializable -
struct S{
char Name[20];
int score;
void Serialize(CFile &file);
void Unserialize(CFile &file);
}
void S::Serialize(CFile &file)
{
WORD wStrLen = (WORD)strlen(Name);
file.Write(&wStrLen, sizeof(WORD));
if (wStrLen > 0)
file.Write(Name, wStrLen);
file.Write(&score, sizeof(int));
}
void S::Unserialize(CFile &file)
{
WORD wStrLen;
file.Read(&wStrLen, sizeof(WORD));
if (wStrLen > 0)
file.Read(Name, wStrLen);
Name[wStrLen] = '\0';
file.Read(&score, sizeof(int));
}
To write an S object to a file, call Serialize().
To read an S object from a file, call Unserialize().
Also, since you're using MFC, MFC's built-in CObject serialization is available.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi!
Need help to copy string in the structure variable .
following is my structure,
struct argument_list
{
WCHAR *pszInFile;
WCHAR *pszOutFil;
what should i have used here string or char *?
char* Host; // Initially I had used string but strcpy function does not support to copy the string
char* UserID;
char* InitPackageRequest;
char* ScriptFile;
};
I have made this structure for the thread. to pass the parameter.
for that i have used the following.
struct argument_list *l;
l=(argument_list *)malloc(sizeof(argument_list));
<br />
<code>is lstrcpy require here?
l->pszInFile=bufferwithpath;
l->pszOutFil=w_Output;
l->_ProtectSet=_ProtectSet;
l->hList=hList;
//l->Host(HOST);
l->Host=NULL;
strcpy(l->Host,HOST); //got error here
l->hwndEncrypt=hwndEncrypt;
l->hWndinoutfiledir=hWndinoutfiledir;
l->hwndParent=hDlg;
l->InitPackageRequest=NULL;
strcpy(l->InitPackageRequest,sINIT_PACKAGE_RESPONSE.c_str());
l->Port=PORT;
l->ScriptFile=NULL;
strcpy(l->ScriptFile,COMMUNICATOR_SCRIPT_FILE_PATH);
l->UserID=NULL;
strcpy(l->UserID,UserID.c_str());
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: strcpy(l->Host,HOST); //got error here
You got an error because there is no memory associated with the 'Host' member - it's just a pointer. You must either: 1) allocate memory before the strcpy - for example, l->Host = malloc(...); OR you can change the struct to a specific size for the 'Host' member - for example, char Host[100].
You seem to be confused about the difference between a char* pointer (char *s), and an array of char's (s[100]). You can use either one in the strcpy() function, but if you want to use a pointer, be sure you know where the memory has been allocated.
|
|
|
|
|
Thank you very much
sir !
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
|
Hi
All
I am doing one application in VC++,MFC in which i have to use ToolTip control with font other that default font of system.So if any body have some hint about this query then plz forward me.
Thanks
aaamm
|
|
|
|
|
hello
i'm using HRESULT GetFileDuration(Qword* duration) in win32 to get duration.
For this function i have to add "wmsdk.h and wmsdkidl.h" header files
When i add these files by giving appropriate path i'm facing errors
syntax error : identifier '__RPC__in' c:\wmsdk\wmfsdk11\include\structuredquery.h
syntax error : identifier '__RPC__out' c:\wmsdk\wmfsdk11\include\structuredquery.h ........
there are around 45 such errors
help me to solve this problem
thanks!!
|
|
|
|
|
Please use the window media format sdk 9.5. in place of 11.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Hi all,
My Application uses RegCreateKeyEx to create a registry.This appilcation has to work in both windows XP and Vista. In windows XP it create registry successfully ,But in Vista it fails to create registry ...
How do i Solve it ....
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: But in Vista it fails to create registry ...
Vista has lots of restrictions, dealing with registry. You may like to read UAC for that. Search for UAC on MSDN .
Prasad
MS MVP - VC++
|
|
|
|
|
Thanks for your reply
Any sample code available to just create a registry in windows Vista ...
Manjunath S
GESL
Bangalore
|
|
|
|
|
I faced the same problem with my application.
I used a manifest.xml in my application as a resource and it solved the problem.
Here are the contents of that manifest.xml file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApp"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="highestAvailable"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Call InitCommonControls() in the InitInstance() of ur application
BOOL CURApp::InitInstance()
{
InitCommonControls();
--------------------------
----------------------
}
U can follow these steps to include manifest.xml in ur project.
Once writing manifest.xml is completed, you will want to add the manifest.xml file to your project in the resource editor. In Visual Studio 6, hit Ctrl+R to add a new resource, select all files and double click manifest.xml to add the file. When you see the custom resource dialog, enter the number "24" as the resource type and hit OK. Once imported, right click on the resource to open the properties window and change the ID to the number "1".
Sameer Thakur
|
|
|
|
|
Thanks Sammer for ur valuable reply...
Iam using Visual studio installer to install an application.In the installer i have a custom action DLL.In this DLL before installing the application i have to check the registry whetheir any entry with name same as my application name is present,if present take the path entered there, if not create a registry entry named with my applciation name....
Any tips to do above in vista ....
Manjunath S
GESL
Bangalore
|
|
|
|
|
Logically.....
You can add that xml file as a resource in a DLL that u are using as a custom action DLL.(No need to call InitCommonControls() in that case.)
By doing that ur DLL will get elevated privileges to read/write registry entries on Vista.
Sameer Thakur
|
|
|
|
|
Hi sameer
Can u tell me what actually done in this XMl...
How it helps to edit registry
And how Custom Dll Handles it...
Manjunath S
GESL
Bangalore
|
|
|
|
|
In Vista there is a concept of User Account Control (UAC) by which it prevents any major changes in registry (though you are logged in as an Admin).
To enable registry changes, we need to provide higher privileges to the application.
To do this there is a tag in manifest.xml …
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="highestAvailable"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
Here we are granting the “highestAvailable” privilege to the application/DLL which ultimately grants the permission to ur application/DLL to access (Read/Write) registry.
Sameer Thakur
|
|
|
|
|
Thanks sameer
I will try this and udapte ...
Manjunath S
GESL
Bangalore
|
|
|
|
|
What happens on Vista? Post your code.
|
|
|
|
|
Hi guys,
I tried with embedding the manifest.xml in my Dll as posted in the previous reply to write registry entry in windows vista. But this fails to create any effect (my Dll could not create the registry entry)
Manjunath S
GESL
Bangalore
|
|
|
|
|
The XML that specifies what execution level you want only makes sense for EXEs, not DLLs, since the execution level applies to a process as a whole.
|
|
|
|
|
Hi Mike,
How can i achieve ( writing to registry ) In vista using DLL...
Manjunath S
GESL
Bangalore
|
|
|
|
|
Please refer this[^].
Regards,
Paresh.
|
|
|
|
|
HI paresh,
Any sample code to writing a registry entry In vista using DLL...
Manjunath S
GESL
Bangalore
|
|
|
|
|
Hi,
In my poject want to disable and enable ToolBar Button(save,open,new..)
at runtime using view class.
I had used following code but this code not work properly(abnormal termination error are occure)
CToolBar m_wndToolBar;
m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);
m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE);
Please help me....
|
|
|
|
|
mohindar_kks wrote: m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);
Are you sure, GetToolBarCtrl is returning some valid pointer. Probably, it is returing NULL value.
mohindar_kks wrote: (abnormal termination error are occure)
This statement leads to above guess.
Prasad
MS MVP - VC++
|
|
|
|