|
Dear All,
I want to write an XML file into shared memory.
I have an XML file or variable of MSXML2::IXMLDOMDocument2Ptr has the whole content.
I need to write this content into shared memory variable that is returned by MapViewOfFile API.
How can i do this ?
Kindly Help me.
Thanks.
-- modified at 1:03 Thursday 23rd November, 2006
|
|
|
|
|
Since MapViewOfFile returns a pointer to shared memory:
<code>LPVOID ptr = MapViewOfFile(. . .)</code>,
I think you should use it as the destination in a string-copy operation:
<code>lstrcpyW((LPWSTR)ptr, xml)</code>,
where xml is the XML string to by copied. Probably it can be obtained from your IXMLDOMDocument2 object like this:
<code>_bstr_t xml = myDocument->xml</code>.
I hope this helps.
|
|
|
|
|
I am saving one bitmap in one .bmp file,
but it is in inverted format something wrong i did.
I used two structure in my code BITMAPINFO and BITMAPFILEHEADER and then i write it into .bmp file.
1
PLEASE suggest me..
1>which property shall i change to get non-inverted bitmapformat.
OR
2>How to invert the inverted format which i got.
ABHIJIT
|
|
|
|
|
You say inverted, but do you mean upside down? You could try using positive or negative figures for the bitmap height paramater of BITMAPINFO.
|
|
|
|
|
Thank you,
i will try and reply you!!!
see u.
|
|
|
|
|
Thanks for reply!!!!!!!!!!!
I used this code please tell me any correction....
//This is for getting data from clipboard in CBitmap's object.
OpenClipboard();
Glb=EnumClipboardFormats(0);
HANDLE hBitMap = GetClipboardData(Glb); //getting from clipboard
if(hBitMap == NULL)
{
AfxMessageBox("Error in Capturing Image");
return;
}
//CBitmap * bmp = CBitmap::FromHandle(hBitMap);
CBitmap bmp;
if(!bmp.Attach((HBITMAP)hBitMap))
{
AfxMessageBox( "Error in Loading Image" );
}
BITMAP bitmap ;
bmp.GetBitmap(&bitmap);
int size = ((bitmap.bmWidth)*(bitmap.bmHeight)*(bitmap.bmBitsPixel))/8;
BYTE *lpBits = new BYTE[size];
::GetBitmapBits((HBITMAP)hBitMap,size,lpBits);
WriteBmp("C\\Patient.bmp",&bitmap,(int*)lpBits);
CloseClipboard();
}
For writing ang saving .bmp file.......
void WriteBmp(char* name,BITMAP *bmp,int* data)
{
BITMAPINFO Bmi;
memset(&Bmi,0,sizeof(BITMAPINFO));
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = (bmp->bmWidth);
Bmi.bmiHeader.biHeight = (bmp->bmHeight);
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bmp->bmBitsPixel;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = bmp->bmHeight*bmp->bmWidth*bmp->bmBitsPixel/8;
FILE* image = fopen (name,"wb");
if(image==0)
return;
int h = abs(Bmi.bmiHeader.biHeight);
int w = abs(Bmi.bmiHeader.biWidth);
Bmi.bmiHeader.biHeight=h;
Bmi.bmiHeader.biWidth=w;
int sz = Bmi.bmiHeader.biSizeImage;
BITMAPFILEHEADER bfh;
bfh.bfType=('M'<<8)+('B');
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER);
bfh.bfSize=sz+bfh.bfOffBits;
bfh.bfReserved1=0;
bfh.bfReserved2=0;
fwrite(&bfh,sizeof(bfh),1,image);
fwrite(&Bmi.bmiHeader,sizeof(BITMAPINFOHEADER),1,image);
fwrite(data,sz,1,image);
fclose(image);
}
|
|
|
|
|
We are creating a Document Management System. In that a user can open the document with associated application.
We need to show a lock icon if the file is already open. We open the file in thread using shell execute and then user WaitfForsSingleObject of detect if the file is closed. But if the multiple files are opened (like two files are opened in Acrobat) we are not able to detect if the file is closed.
Can some open suggest some API or oter method for detected when the file is closed.
|
|
|
|
|
Hi,
Some time ago I wrote similiar DMS for some company, but my idea is slightly different than yours.
Instead of passing document directly to the application which is associated as default, you could create another file as temporary with additional parameters (temporary, remove on file close, share read/write), copy content of original file to it, open the file with associated app (don't close its handle).
Pros:
- original file doesn't need to be locked,
- you can track changes,
- you can let user decide wheter the original file should be updated or not,
- you don't have to care about temporary file, unless user closes it,
- you can monitor changes made to that file, by using handle to it.
Cons:
- a bit more code to write, than in simple handle checking
As for your way, there's a nice tool you can use: Sysinternals - Handle (by dumping its output to your redirected standard output).
Regards
|
|
|
|
|
In windows exporer if I open a file say "text.doc" present in "C:\office docs" folder. Now when performing operation lre renaming,moving or deleing that folder in windows will return error.
Can If a folder in windows file systemis locked befor performing these operation programmatically.
Can some one suggest some shell API or SDK function to do the job
|
|
|
|
|
Have a look at the CFile::Open() method. If it returns zero, then the pError parameter in it will have a description of the error.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
The folder is not locked. It is file which is locked as opened and sanity checks for move,delete operations returns failure, because some/one file cannot be removed. What system really does when you order it to move folder, is to copy & delete every single file in folder, and when error occurs (like when file is opened), an error message is displayed, but folder is never being locked.
Regards
|
|
|
|
|
Hi All,
I have a class derived from CFormView.
I have to show ToolTip for some buttons for the view drived from CFormView.
I have done the below steps but, the tool tip is not showing...
Say m_ToolTip is an object for CToolTipCtrl,
In OnInitialUpdate()
m_ToolTip.Create(this);
m_ToolTip.Activate(TRUE);
CRECT rect(1, 1, 1, 1);
m_ToolTip.AddTool(this, "My Tool Tip", &rect, BTN_ID);
In OnSize()
m_ToolTip.SetToolRect(this, BTN_ID, &newRect);
In PreTranslateMessage()
if (pMSg->Message == )
m_ToolTip.RelayEvent(pMSG);
Is there any thing to do more.. or i'm wrong in some where...
Do your Duty and Don't expect the Result
|
|
|
|
|
AFAIK, you forgot to handle notifications (WN_NOTIFY) for the parent window of every control you have handle assigned to.
Regards
|
|
|
|
|
Hello All,
I have small and simple COM program to access a Add function in Dll and I am accessing this function from main program. For the simple add function it is working, interface and dll files are working properly.
For this interface I am trying to add one more function by name getdate() which of return Char* .. can any one please help how to declare the getdate() function in interface ???
Below are declaration and files with there names ….
// File interface.h
// This file contains interface related declarations.
#ifndef _A_INTERFACE_H_
#define _A_INTERFACE_H_
DECLARE_INTERFACE_(IMyA,IUnknown)
{
STDMETHOD_(LONG,MyAdd)(INT,INT) PURE;
};
--- ---
--- ---
file :- MyA.h
class CMyA : public CCmdTarget
{
DECLARE_DYNCREATE(CMyA)
CMyA();
-- -- -- - - -- -- -- - -
-- -- -- - - -- -- -- - -
-- -- - -
-- -- - --- -- -- - --- -- -- - -
protected:
virtual ~CMyA();
DECLARE_MESSAGE_MAP()
BEGIN_INTERFACE_PART(MyAObj,IMyA)
STDMETHOD_(LONG,MyAdd) (INT,INT);
END_INTERFACE_PART(MyAObj)
DECLARE_INTERFACE_MAP()
DECLARE_OLECREATE(CMyA)
};
// MyA.cpp : implementation file
-- -- -- --- -- --
//IMyA Functions
STDMETHODIMP_ (LONG)
CMyA::XMyAObj::MyAdd (INT x,INT y)
{
return (x+y);
}
-------------------------------
// function to be added to Interface can u please help me how to declare this function in interface.
char* getDate()
{
struct tm *newtime;
char am_pm[] = "AM";
-- - - -
--- - -- - - -
}
Thanking you,
Suresh H
|
|
|
|
|
I am programming a MFC project using Visual C++. I encountered a problem with the following code snippet.
The code snippet could be compiled successfully.However, an error occurred when running the line
<br />
free(SampleDocName); <br />
in the following code snippet, free(SampleDocName) causes error if the line
<br />
SampleDocName[ SampleDocNam_Len ] = '\0';<br />
is not used.
<br />
char * SampleDocName;<br />
int SampleDocNam_Len = m_EDITBOX_ExampleText.LineLength(0);<br />
SampleDocName = (char *) malloc(sizeof(char) * (SampleDocNam_Len+ 1 ) );<br />
m_EDITBOX_ExampleText.GetLine(0, SampleDocName );<br />
<br />
SampleDocName[ SampleDocNam_Len ] = '\0';
<br />
<br />
free(SampleDocName); <br />
I do not why. Please help me.
|
|
|
|
|
Why are you using malloc() and free() in C++ code, you should be using new and delete . Also why use the call to sizeof(char) in you malloc() call? This is pointless as the size will always be a constant 1.
Check the value of your SampleDocNam_Len and make sure no stupid values are being passed into malloc() , also make sure you are not writing past the end of the array.
|
|
|
|
|
I think you should use
GetLine( 0, SampleDocName, SampleDocNam_Len );
instead of
GetLine( 0, SampleDocName);
since for the latter you need to pass the line lenght on the first word of the buffer (MSDN):
lpszBuffer
Points to the buffer that receives a copy of the line. The first word of
the buffer must specify the maximum number of bytes that can be copied
to the buffer.
Also will be nicer if you use the C++ allocation pair new/delete
(you are free to use free of course, but as matter of style...).
|
|
|
|
|
Hi all,
Please any body tel me how to hide a tab control from the property sheet.
I tried
GetTabControl()->ShowWindow(SW_HIDE);
But when executing this all the tab control of the sheet goes to hide.
But i want to hide a single tab control.
Please tel me anybody knows it.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Ok..Now no need to any reply for me.
I solved it.
I tried RemovePage of Sheet.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Hi, do you guys know how to set(change) the short file name of a specific file inside visual c++? Is there any API doing that?
Thanks!
|
|
|
|
|
The short file name of a long named file is the first six chars, a ~ and a number, starting with 1 ( depending on how many have those 6 chars ). Not sure if it goes to 5 chars for > 9 files.
You can't set it AFAIK
Christian Graus - C++ MVP
|
|
|
|
|
I think you actually cannot.
|
|
|
|
|
If you're on XP+ and the file is on an NTFS volume, you can use SetFileShortName() .
|
|
|
|
|
Can someone give me a real, WORKING - example(code) of how to "CreateDirectory" , "CopyFile" and "ChangeDirectory" in MFC.
I know how to use these "verbs/tokens" in non-MFC programs, but they aren't available to you in MFC; because you can't "#include <window.h>" in MFC.
So how do you do the same things in MFC. Example code PLEASE!
A C++ programming language novice, but striving to learn
|
|
|
|
|
windows.h is very much included in MFC.
Here's a working sample
::CreateDirectory(_T("C:\\TESTTEST"), NULL);
HANDLE hFile = ::CreateFile(_T("C:\\TESTTEST\\test.tst"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
::CloseHandle(hFile);
::CopyFile(_T("C:\\TESTTEST\\test.tst"), _T("C:\\test.tst"), TRUE);
::SetCurrentDirectory(_T("C:\\TESTTEST"));
|
|
|
|
|