|
Hi .. thanks for prompt reply. I am getting a file in cstring and i want to parse. The parser take the data in LPBYTE format and file data contain few words in languge other than english thats why i am taking cstring to store it. But when i convert cstring to lpbyte only first character get stores. Meanwhile i am going through the link you have sent.
amit
|
|
|
|
|
amit.code wrote: I want to convert a cstring into LPBYTE...
How are you doing it? Something like:
CString name("Name");
const LPBYTE lp = (const LPBYTE) (LPCSTR) name; amit.code wrote: ...but each time i convert it only first character get stored in the LPBYTE and rest of the string is truncated.
How are you verifying this?
Is Unicode defined?
"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 .. i have also tried the method that you mentioned. I am parsing that whole data that comes in lpbyte but it shows only one character. During debugging I am verifying it also throughg watch window.
Thanks
amit
|
|
|
|
|
Could it be that you are feeding a unicode string to something that expects a simple ASCII string? Also note, that LPBYTE is porbably not recognized as a string by the debugger, thus it will only show you the pointer's value (the address it is pointing at) and maybe the one byte it is pointing at.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
hi.. thanks for reply. You are right in your first point, when i convert cstring to string and than pass it to LPBYTE than whole data is being assigned and yes we can see the whole data during debug in lpbyte but during conversation from cstring to string data not written in english language being wrongly modified and there what i am getting problem. Thats why I am trying to convert cstring directly to lpbyte.
Thanks
amit
|
|
|
|
|
Then -as other people already pointed out- please show us how you actually do the conversion.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Try this.
BYTE string[MAX_PATH];
::WideCharToMultiByte(CP_ACP, 0, (LPCTSTR)cstring, -1, (LPSTR)string, MAX_PATH, 0, 0);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for reply.. i have tried your suggestion but it fails to convert character of other language. Meanwhile i found a workaround solution of this one.
amit
|
|
|
|
|
Nice change to ACTUALLY see a code example that actually works...
Too many times I have to weed out the trash where people don't have the common courtesy of showing an actual code example.
They beat the dead horse to death without any clue to help those that aren't intimately familiar with all the ins and outs of C!
Thanks "Superman"!
---
Most of my programming of the last 5 to 10 years has been in Visual Basic where strings are strings.
C++ has so damn many string types that it is very easy to get confused when converting the different flavors of strings to anything and back.
If I had my way, more people would learn to program in Assembly where data is data and you have to determine what to do with it.
My first programming job for the first 5 to 7 years was purely in Assembly Language. I learned a bunch of things very quickly that way.
We all too lazy in the last 20 years it seems when programming.
Bill G.
Senior Software Engineer / Systems Analyst for over 32 years.
Age 53
|
|
|
|
|
I have an application developed in VC++6.0 using MFC MDI application type. I want to convert my application to VC++.NET.
Pls List out the steps about how to convert my application to VC++.NET?
Also Provide me any automation tools for converting the VC++6.0 application to VC++.NET (i.e., converting the .DSP, .DSW files to .SLN files in .NET)
|
|
|
|
|
What does it tell you when you try to a open VC6 solution with a VC++.net IDE?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
- Open up the 6.0 DSW (or DSP) of your project in Visual Studio.NET (year of your choice) and the IDE will ask you
to convert the project files.
- Click Yes/OK
- Once that is done, save, and rebuild your project.
- Fix all the new errors and warnings.
- Test your application.
This signature was proudly tested on animals.
|
|
|
|
|
Is there any automatic tool for doing this conversion.
|
|
|
|
|
Do you want to convert your MFC application into a .NET application ? Then one can activate the /CLR compiler switch and it will compile it as managed C++.
http://msdn.microsoft.com/en-us/ms173265.aspx
Later you can convert your managed C++ into C#, and change your MFC dialogs into WinForms.
Or do you just want to upgrade to a newer version of Visual studio ? If so then Visual Studio will automatically upgrade the project files of you MFC application. And you might have to resolve some issues as the C++ compiler is more standard compliant.
|
|
|
|
|
I want to connect the excel file to my MFC gui grid . Also As any change occured into the cell of the
excel file it also reflect into the MFC gui . Is there any api for both functionality.
Trioum
|
|
|
|
|
You could set up the Excel file as an ODBC data source and then use standard database functionality to connect that to your grid?
As for getting notifications of changes...not sure about that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi all,
I am trying to add excel add-ins programmatically through C++ code.
It is srunning fine on xp or lower OS. But it is giving an 'Unhandled exception' on Vista.
m_xlAddins = xl.GetAddIns();
if(xl.GetVersion()=="12.0")
{
m_xlAddin = m_xlAddins.Add(strAddin,covTrue);
m_xlAddin.SetInstalled(TRUE);
}
Could anyone help me please?
|
|
|
|
|
SRKSHOME wrote: m_xlAddin.SetInstalled(TRUE); //---> giving an error on vista.
Could this be attempting to write to a location on the disk or in the registry for which it does not have sufficient privileges?
"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 there.
I have created a dll(text based logger) that can be used to create a text based log.
Now, my problem is, let's say, this component is being used by several other components and those several components are logging into the same text file. Now, that’s a problem...Synchronizing problem.
Need suggestions to resolve this problem.
Any work around will be appreciated.
Thanks
PanB
|
|
|
|
|
Single-threaded - terminate every stream output operation with std::endl to properly flush the stream before the next stream operation.
Multi-threaded - you could use a critical section to serialize use of the log file - something like:
std::ofstream logFile;
CRITICAL_SECTION csLogFile;
: : : : : :
EnterCriticalSection(&csLogFile);
logFile << stuff << std::endl;
LeaveCriticalSection(&csLogFile);
Alternatively, put all the logging information in one thread and send messages to that thread to log (you could share a queue of strings between threads and have a synchronised function that enqueued a log message?)
Multiple processes? - you could do something with file locking? But not with vanilla C++ - you'll need some OS specific functionality. And even then, I wouldn't guarantee it working on network drives.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart my requirement is implement synchronisation across network. On the basis of your exp. what's your suggestion? Give me just a pointer, after that i will dig the concept
|
|
|
|
|
PankajB wrote: implement synchronisation across network
Multiple machines?
If that's the case, I'd be tempted to use RPC or some TCP/IP service, so you have a single point of contact for logging.
File-locking is not (I seem to remember) particularly recommended for files on a network server, so I'd really be tempted to use a client-server mechanism.
The easiest way would be to have a very primitive web server on a machine (you can implement one in a few hundred lines of code[^] - that one's Unix specific, but (from experience) I know you can reuse 95% of the code on Windows) that, when you POST ed a message to a particular URL, would write that message to the log-file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
A straight questions – By any mean, can we open any file in exclusive lock mode.
I mean, if I open a file, it will be locked automatically and then, in case any other process try to use the same file, the process can get that state.
What I am planning is, in case I can find that the file is locked, I will create a temp file and write my log into in that file. And my logger will be intelligent enough to find whether any temp files exists and if they do, then it will copy the content to the mail file and will delete temp files.
May be what I said is just an imaginary idea….but if I can find out that the file I want to use is locked, then I will be able to implement this approach.
|
|
|
|
|
PankajB wrote: By any mean, can we open any file in exclusive lock mode
Yes - use CreateFile with 0 for the dwShareMode parameter.
Anyway - that scheme sounds feasible
Some points...what happens if you can open the log file but a temp file is locked? Does out-of-order insertion into the log matter?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have got a trouble of GDI+, my code is like this:
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(&rect);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
dcMem.SelectObject(&bitmap);
Graphics graphics(dcMem.m_hDC);
SolidBrush brushBKGnd(Color(0,0,0));
//freeze at here
graphics.FillRectangle(&brushBKGnd, Rect(rect.left, rect.top, rect.Width(), rect.Height()));
The code will freeze at the last line, I don't know why, please help me.
|
|
|
|