|
|
|
Hi all,
I have a function (see following function), takes a structure of file information and file name. It prints the file with appropriate exe file according to their extention.
file information structure contains: file name, file type, file date, file size...etc.
I dont' get any problem printing the first file but crash for second file to print..
Is it because of the way I defined ShellExecuteInfo???
If so, what is the problem and how to fix it???
Thank you.
<br />
int myfunction(FileInfo afile, CString fileName)<br />
{<br />
int wordfile=0;<br />
CString msg;<br />
CString filetype = afile->type;<br />
<br />
int found =0;<br />
<br />
SHELLEXECUTEINFO lpExecInfo;<br />
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); <br />
lpExecInfo.lpVerb = "open";
lpExecInfo.lpDirectory = NULL; <br />
lpExecInfo.nShow = SW_SHOW ;
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
<br />
if(filetype.CompareNoCase(".xls") == 0 || filetype.CompareNoCase(".csv") == 0 || filetype.CompareNoCase(".csv") == 0|| filetype.CompareNoCase(".wks") == 0 || filetype.CompareNoCase(".zip")==0)<br />
{ <br />
<br />
else if(filetype.CompareNoCase(".xls") == 0 || filetype.CompareNoCase(".csv") == 0|| filetype.CompareNoCase(".wks") == 0)<br />
{<br />
found = 1; <br />
AfxMessageBox(" EXCEL FILE FOUND !!!\n\tPrint it manually"); <br />
lpExecInfo.lpFile = "j:\\smp\\smp\\printExcel\\debug\\printexcel.exe";
lpExecInfo.lpParameters = fileName;
msg.Empty();<br />
msg = "Printing " + fileName + " completed.\n Press OK to continue...";<br />
<br />
<br />
}
<br />
else if(filetype.CompareNoCase(".doc")== 0 || filetype.CompareNoCase(".rtf")==0 || filetype.CompareNoCase(".htm") == 0 || filetype.CompareNoCase(".html")==0)<br />
{<br />
wordfile = 1;<br />
found = 1; <br />
lpExecInfo.lpFile = "j:\\smp\\smp\\wordprinting\\debug\\wordprinting.exe";
lpExecInfo.lpParameters = fileName;
<br />
}
<br />
else if(filetype.CompareNoCase(".msg")==0)<br />
{<br />
lpExecInfo.lpFile = fileName;
<br />
}
<br />
ShellExecuteEx(&lpExecInfo); <font color="red">here where I got error for second file.</font><br />
<br />
if(lpExecInfo.hProcess !=NULL)<br />
{<br />
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);<br />
::CloseHandle(lpExecInfo.hProcess);<br />
} <br />
if(wordfile != 1)<br />
MessageBox(msg);<br />
<br />
}
return found;<br />
}<br />
|
|
|
|
|
You didn't say what the error is, but I see two problems. First, the fMask member of the struct is not initialized, so it has garbage in it. It's always a good idea to zero-init structs. Second, for the hProcess member to be filled in, fMask must include SEE_MASK_NOCLOSEPROCESS.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
yes.. you were right.. i missed that..
the error was just crash.. you know general protection error.
Thanks.
|
|
|
|
|
Howdy,
I have a SDI (chat) app, in my CView I create 2 Rich Edit windows one fills 80%(top of CView receive text) and the other fills the last 20% (bottom Send text) they are both classes derived from CRichEditCtrl.
For some reason these 2 controls are not receiving my SendMessage commands from CView on 9x machines. (The sendmessage commands work fine on Windows 2k.) I have looked up the messages on MSDN and they should work on any 9x platform and nt 3.51 and up with RichEdit 1.0, the messages are:
EM_SCROLLCARET
EM_EXSETSEL
EM_GETEVENTMASK
Plus my Context Menus containded in my derived RichEdit classes do not display on 9x machines.
I know this is probably vague but does anyone have any suggestions?
|
|
|
|
|
Use MSDEV Spy++ to figure out if messages are really processed or not.
Back to real work : D-27.
|
|
|
|
|
Hi,
I do not know why I can not control "Size" of the chars print out for most of the Default Printers (works only on Window XP)!
In Window XP if I change the follwing command ... then it changes the size ( 9 & 72), but for others ... nothing affected! Can someone help me to pin-point the problem?
<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
Here is my whole codes:
<br />
CPrintDialog printDlg(FALSE, PD_RETURNDEFAULT | PD_RETURNDC);CHeaderCtrl *pHeader = m_saleReport.GetHeaderCtrl();<br />
<br />
int i;<br />
<br />
if (printDlg.DoModal() == IDCANCEL)
return;<br />
<br />
CDC dc;<br />
CPrintInfo Info;<br />
CFont oFont;<br />
<br />
dc.Attach(printDlg.GetPrinterDC());
dc.SaveDC();
dc.m_bPrinting = TRUE;<br />
<br />
CString strTitle;
<br />
DOCINFO di;
::ZeroMemory (&di, sizeof (DOCINFO));<br />
<br />
di.cbSize = sizeof (DOCINFO);<br />
di.lpszDocName = strTitle;<br />
<br />
BOOL bPrintingOK = dc.StartDoc(&di);
<br />
int ppiX = dc.GetDeviceCaps(LOGPIXELSX);<br />
int ppiY = dc.GetDeviceCaps(LOGPIXELSY);<br />
<br />
int x0,y0,x1,y1;<br />
x0 = ppiX * (8 - 5.5)/2;
y0 = ppiY;
x1 = dc.GetDeviceCaps(HORZRES);
y1 = dc.GetDeviceCaps(VERTRES);
<br />
Info.m_rectDraw.SetRect(x0,y0,x1+400,y1);
<br />
<br />
LOGFONT lf; <br />
memset(&lf, 0, sizeof(LOGFONT));
::ZeroMemory(&lf, sizeof(LOGFONT));<br />
<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Garamond");
<br />
oFont.CreateFontIndirect(&lf);
dc.SelectObject(&oFont);
<br />
CString text("A") ;<br />
CSize csText = dc.GetTextExtent(text) ;
<br />
int lines_per_page = (int)(Info.m_rectDraw.Height() / csText.cy) ;<br />
int lines_in_listbox = m_saleSummary.GetCount();<br />
int headercolumn = pHeader->GetItemCount();<br />
int line_printing = 0 ;<br />
<br />
HDITEM hdi;<br />
TCHAR lpBuffer[256];<br />
bool fFound = false;<br />
<br />
hdi.mask = HDI_TEXT;<br />
hdi.pszText = lpBuffer;<br />
hdi.cchTextMax = 256;<br />
<br />
Info.SetMaxPage((lines_in_listbox / lines_per_page) + 1);<br />
<br />
for (UINT page = Info.GetMinPage();<br />
page <= Info.GetMaxPage() && bPrintingOK; page++)<br />
{<br />
Info.m_nCurPage = page;<br />
dc.StartPage();
CString Text; <br />
Text = m_saleReport.GetItemText(i,j);
dc.DrawText(Text, CRect(x, y, x + Info.m_rectDraw.Width(), y + csText.cy), DT_EXPANDTABS);<br />
}<br />
<br />
dc.EndPage();<br />
dc.EndDoc(); <br />
dc.RestoreDC(-1);
dc.DeleteDC() ;
Many thanks
|
|
|
|
|
Hi guys,
I'm developing an app and having a complete nightmare trying to support Windows 98! It runs solid like a rock on Windows 2000 and Xp, but with 98 it just crashes in the oddest of places. One of these is inside the AlphaBlend() function, which is a new function included in the November 2001 Platform Sdk. It is supposed to work under 98 no problem.
The AlphaBlend() code crashes inside msimg32.dll, and I read somewhere that you must not package this dll with your product... I am currently not doing this, but wonder if perhaps I should anyway ?
Besides saying that Windows 98 licks the donkey's butt, does anyone have any ideas what could be going wrong? I'm debating just adding fine print saying something like "Run on Windows 98 at your own risk"
swinefeaster
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Swinefeaster wrote:
One of these is inside the AlphaBlend() function, which is a new function included in the November 2001 Platform Sdk. It is supposed to work under 98 no problem.
No, to get it compiled fine, you probably use WINNT_VER=0x0500 or something like that. Doing so, you link with a W2K+ vtable from any dll. That's probably why it fails miserably on 9X systems.
That's certainly bad, but I believe you must have two separate builds.
Back to real work : D-27.
|
|
|
|
|
Well it does compile fine. It just doesn't run fine!
But nevertheless, I tried defining _WIN32_WINNT 0x0500 in StdAfx.h, and rebuilt the whole thing, and now it even crashes in the toolbar classes and all sorts of other places
What do you mean by a vtable? Isn't a vtable the virtual lookup table used in virtual functions? Or am I missing something?
Also, it doesn't make sense to have multiple builds... I mean all the other software out there has a single install for 98/Me/2000/Xp ???
Thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Swinefeaster wrote:
Well it does compile fine. It just doesn't run fine!
I know.
Swinefeaster wrote:
Also, it doesn't make sense to have multiple builds... I mean all the other software out there has a single install for 98/Me/2000/Xp ???
May be. You could end up with a proxy dll that will, depending on the OS on which it's running, will load one of two child dlls : one for systems that don't support alpha-blending, one for those which do.
Back to real work : D-27.
|
|
|
|
|
I downloaded this sample from MSDN about enumerating processes under Win9x. It uses Psapi.dll (so includes Psapi.h) to access functions used to retrieve all running processes, here is the code:
#include <<windows.h>>
#include <<stdio.h>>
#include <<psapi.h>>
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
else return;
}
else return;
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
cProcesses = cbNeeded / sizeof(DWORD);
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
Now when i try to compile this is compiles fine, but when it runs it gives me the error: "The PSAPI.DLL file is lonked to missing export NTDLL.DLL:NtAllocateVirtualMemory"
Now i did a search for NTDLL.DLL and it is in my windows system directory, so i opened it up with Dependency viewer and it could not find a function NtAllocateVirtualMemory.
Now what is wrong here? do i have a wrong DLL?? Even if i did, there is another question i asked myself. You see i opened up Taskmon.exe in Dependency viewer and it just uses the standard libraries like GDI.DLL, USER32.DLL, etc...
So it has to be possible to enumerate processes without the PSAPI so you can avoid the DLL problem. I wouldn't know how though...
If anyone has any ideas, please share them, any help is appreciated.
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
I have this exported function in NTDLL.DLL. And am running W2K SP2.
Back to real work : D-27.
|
|
|
|
|
I forgot to tell you, PSAPI.dll is not for W9X systems. It's too bad you got the sample from MSDN and you didn't get the sample in full length.
On W9X, you use CreateToolhelp32Snapshot and an enumerator. Searching MSDN with PSAPI as keyword brought me the full length sample in rank 1 ! And you have to switch case all possible OSes.
Back to real work : D-27.
|
|
|
|
|
I have a rather large dialog application that really needs a line drawn to divide it into two sections. Its a serial communcations dialog and the top part handles sending out data (32 user filled edits) while the bottom section is responsible for displaying incoming messages ( 14 read-only edits). I have no problem with the Tx/Rx aspects but I would really like to draw a line between the two. I have no experience whatsoever in this area and am looking for an answer that is detailed enough that I can insert it into my code. I created the dialog using the VS 6 project wizard if that matters. From the small amount of reading I've done (looking in CPaintDC and related items in the MSDN library) I didn't get to far. I am sure I can figure this out if I take the time to go through it in detail but I would really appreciate it if someone would just give me a either a walk through or the code I need. If more info is required just ask... I will provide whatever is needed
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
|
|
|
|
|
Forget CPaintDC, add a groupbox and make it as thin as 1 pixel height.
If you can't, because you use grid locking and stuff, just go the hardcore way : open the .rc file and set the 1 there.
Back to real work : D-27.
|
|
|
|
|
As far as I know, I haven't set any grid locking. But I haven't ever delved into this aspect and if you could some code I could either paste or use as a guideline I would truly appreciate it
---------------------------------------------
<i>The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?</i>
<i> - Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!</i>
|
|
|
|
|
You didn't get it right;P. You just need your mouse! in the dialog editor. Insert a groupxbox control, and resize it.
Back to real work : D-27.
|
|
|
|
|
okay.. let me try that...
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
|
|
|
|
|
sorta does the job.. but the line it draws in faint.. how can I make it darker?
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
|
|
|
|
|
To get a solid black line, use a statement like the following in your .RC file:
CONTROL "",IDC_STATIC,"Static",SS_BLACKRECT,262,295,142,1
In IDE terms, this is a 'picture' control, with the type set to 'Rectangle' and the color set to black. In actuality, it is a static control with the style SS_BLACKRECT, which draws a black rectangle.
Software Zen: delete this;
|
|
|
|
|
Use a picture control and set its type to Rectangle, then adjust it to the size you need. Default color is black but it also supports white and gray. If you need the thickness smaller than 5 dialog units, temporarily set your layout grid height to a smaller value.
|
|
|
|
|
Hello,
I want my program able to burn a CD/DVD. Could you give me a bit of idea how to support cd burning in my application? Do you know any good quality cd burning library?
Thanks!
|
|
|
|
|
If your program will only run in Windows XP, you can use the IMAPI API. If you need other platforms, you'll need some 3rd party products and APIs.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|