|
Hi,
How do I retrieve data in 5th parameter of this API. Since I dont know what will be the length of data n how will I allocate memory to this param???
Even if I declare array of maximum size it gives me error "234" i.e. "ERROR_MORE_DATA"
Here is sample code...
DWORD dwretrievedDataType = NULL;
DWORD dwretrievedLenOfData = NULL;
LPWSTR wzretrievedData = NULL;
.
.
.
// I have already given proper values for 1st 3 params
dwretValue = SHGetValue(hkeyRoot, wzkeyPath, wzvalueOfKey,
&dwretrievedDataType, wzretrievedData, &dwretrievedLenOfData);
.
.
.
PLz do let me know asap if anyone knows abt it...
thanks n regards
Supriya Tonape
|
|
|
|
|
Heelo.
The last (sixth) parameter is supposed to be the allocated length of the buffer.
You must set dwretrievedLenOfData to the size of wzretrievedData before the call to SHGetValue.
Now you set it to NULL.
BTW, if you want to zero out a DWORD, the use 0 instead of NULL.
Kakan
|
|
|
|
|
Hi Kakan,
I dont want to hard code any value, like size of 5th param... b4 giving this param as input to 'SHGetValue()' U need to allocate memory for 'dwretrievedData'..I did read abt the documentation of it in MSDN
Thanks in ton for help coz I am done with my problem
bye
Supriya Tonape
|
|
|
|
|
Hello again.
I'm pleased to be able to help you out.
About the buffer size, at some time or another you will have to allocate the buffer for the return value, hardcoded or not...
In general, the Windows functions that return buffers usually has a way to give the coder the size of buffer needed for a particular reply.:
1.
Set the buffer pointer to NULL, and allocated buffer size to 0.
2.
Call the function in question.
3.
The function returns the number of bytes/chars needed for the (real) response.
4.
Allocate that amount of memory för the buffer.
5.
Call the function again, this time with a valid buffer address and the number of allocated bytes.
6.
Obtain the result.
But I'm not sure if this goes for SHGetValue, though. I haven't checked.
But this principle goes for many Windows functions.
Kakan.
|
|
|
|
|
Hi,
No It doesnt work for it. Though it doesnt give any error but buffer size returned is the size of DWORD.
Bye
Supriya Tonape
|
|
|
|
|
I am creating a MS Word document using Automation With VC++(MFC). I want to change the Font Size of the text in the MS Word Document by using Automation with VC++ (MFC).
Thanks
|
|
|
|
|
Hi i posted a Query " How can i run my code in Service mode "
I got quick reply ;
"Kakan" guided me and "ThatsAlok" given link
Thanku guys , four kind help...
But actually my problem is when i click on my project ".exe" file
then it should automatically installed , rather then going to
Comand promt and installing manually....
Thanks in advance.....
Usha
|
|
|
|
|
usha_dolly wrote: But actually my problem is when i click on my project ".exe" file
then it should automatically installed , rather then going to
CreateService Api will help... But beware.. Always check that service existence before installing...
"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
|
|
|
|
|
I have made an application which can convert PPT slides to JPG images using powerpoint type library.
Now i want to port the application to MAC. I m not able to find any developing environment in which i can port it to mac. I have a MAC G4 iBook and Office 2004 for MAC .. Please help me...
my mail address is catbbs7@yahoo.com
Regards
Vishal
|
|
|
|
|
:-OHi all,
Please tell whether we can use
ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE);
to print
1) Text(*.txt) file
2) Document file
3) Excel Sheet
4) Access table
5) Powerpoint Slide
6) Webpages
7) Images Jpg,jpeg,bmp etc.
I am asking this because i used automation to achieve printing for most of these. As an afterthought, it came perhaps i could have done it using ShellExecute also.Am i right in thinking so?i don't know. u know....
then plz tell because if that happens it will make my application really simple & fast without any overhead.
Please Guide.
Regards,
Ankush Mehta
|
|
|
|
|
Ankush Mehta wrote: 1) Text(*.txt) file
2) Document file
3) Excel Sheet
4) Access table
5) Powerpoint Slide
6) Webpages
7) Images Jpg,jpeg,bmp etc.
Try it, if it doenst work then you will need to find another method.
1: Should work
2: Should work
3:Should work
4: Nope, will need to find another method, I would dump it to an excel file and then print that.
5: Nope wont work, have no idea never really worked with power point.
6: Should work.
7: Dont know.
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
thanks sfdougl,
1) Agree
2) Agree
3) Agree
4) Agree,automation is the option in my case because i want to enumerate tables in the database programmatically & then proceed towards printing.i think i am right.plz tell if u have other option to enlist tables in database.
5) it doesn't work in my case
6)I could not manage printing a webpage with ShellExecute.My code is like this:
ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE);
7)Prints only bmp.I changed extension to bmp, printed & renamed filename to original extension
Please tell me about point 6) after trying it out.Also tell me about point 4) if you have something to tell about it.
Regards,
Ankush Mehta
|
|
|
|
|
Ankush Mehta wrote: 4) if you have something to tell about it.
Here is a good quick way to dump a recordset to a excel file, then call shellexecute to print that file. Delete it it after your done.
CString str;
str.Format("SELECT * INTO [Excel 8.0;DATABASE=%s].[%s] FROM [%s]", ExcelFile, Worksheet, table);
Create an ADO Connection object to the database then call.
pConn->Execute(str.AllocSysString(), NULL, adExecuteNoRecords);
To enumerate the tables in an access database try
SELECT MSysObjects.Type, MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type=1;
Ankush Mehta wrote: 6)I could not manage printing a webpage with ShellExecute.My code is like this:
ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE);
Try ShellExecute("explorer.exe","print",m_FileName,NULL,NULL,SW_HIDE);
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
when i use the copy-paste code line given by you following error is generated.i am using VC++ 6.0.
cannot convert parameter 1 from 'char [13]' to 'struct HWND__ *'
Regards,
Ankush Mehta
|
|
|
|
|
Opps, I wasnt paying attention.
Lets see now how did I do it (FYI, Im no where near my dev computer and cant verify this at all so its based off memory, and I often have corrupt memory errors)
ShellExecute(NULL, "print", "explorer.exe", m_FileName, NULL, SW_HIDE);
Or
combine both explorer and file name
CString str = _T("explorer.exe ");
str += m_FileName;
ShellExecute(NULL, "print", str, NULL, NULL, SW_HIDE);
Hows that?
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
-- modified at 4:34 Thursday 8th December, 2005
|
|
|
|
|
No errors,
But no output also just as with the first shell execute statement i sent ...
Ankush Mehta
|
|
|
|
|
Your going to make me work arent yea?
As I said Im not near a computer with VS installed, but I do have MS Word and VBA. This just printed the file.
ShellExecute(0, "print", "C:\workorder.html", 0, 0, 3)
One more thing, ShellExecute returns a HINSTANCE, which can be cast to an int. What is the return? Is should be a value higher than 32.
Google Cache of a website with the error return codes[^]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp[^]
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
-- modified at 6:22 Thursday 8th December, 2005
|
|
|
|
|
well, one last question how to typecast to int......plz answer this one sfdougl...
Ankush Mehta
|
|
|
|
|
Ankush Mehta wrote: well, one last question how to typecast to int
Sure you could do the following,
HINSTANCE hresult = ShellExecute(params)
TRACE("Result of Print %d\n", (int)hresult);
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
I just tested the following and it works in VS6.
HINSTANCE handle = ShellExecute(0, "print", "C:\\WorkOrder.html", NULL, NULL, SW_SHOW );
The only down side that I see here is it prompts the user with the printer settings dialog. All they have to do is click print but still...
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
-- modified at 10:00 Thursday 8th December, 2005
|
|
|
|
|
Hi,
How to open recent files from file menu in MFC application.Which method do we need to override?
|
|
|
|
|
If I understood this question then, here I say...
Just create one MenuItem in your File popup menu with this id.
you can give name something as "Recent Files"
ID_ FILE_MRU_FILE1
To know more about how it works and all, view this Microsoft link its pretty clear
http://www.microsoft.com/msj/0899/c/c0899.aspx[^]
regards,
-OP
|
|
|
|
|
right click in C drive and create a file called "hello.txt" and a folder called "New Folder". Then run this program:
BOOL ret = MoveFileWithProgress("C:\\hello.txt", "C:\\New Folder", NULL, 0, MOVEFILE_COPY_ALLOWED);
DWORD dw = GetLastError();
ret = MoveFile("C:\\hello.txt", "C:\\New Folder");
dw = GetLastError();
Both the MoveFile* calls fail with error ERROR_ALREADY_EXISTS. According to MSDN the target can be either a file or a directory. It is not clear what is going wrong, any ideas anyone?
thanks!
|
|
|
|
|
Hi,
The new file name must not already exists. This is in case of MoveFile.
When the dwflag parameter of MoveFileWithProgress is set MOVEFILE_COPY_ALLOWED it internally uses MoveFile() and DeleteFile() functions. Hence, you get the same error.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Never mind, I identified the problem.
If the source is a file, the target has to be a file name too, it cant be a directory. I misunderstood the MSDN doc for MoveFileWithProgress.
Btw, It is MoveFile and MoveFileEx that call MoveFileWithProgress and not the other way.
thanks!
|
|
|
|
|