|
GetModuleFileName(NULL) .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
When I am trying to build my project in VC++ 6.0, Windows 95,with some files updated, all of my files in that project are also compiling.(I have tried build selection also). can any one suggest what i have to do for compiling only those
files.
Thanks for reply....
Kishore
Kishore
miel, senate
bangalore
|
|
|
|
|
I think the file creation dates dont match the system date. Maybe you developed them on a system with a futuristic wrong date.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
I have written a function that given an Interface GUID, class name, method name, and parameters; it will execute the method. Now I need to get the return values for byref parameters.
I call invoke as follows
hr = pdisp->Invoke(dispid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&dispparams,pval,&excep,&uArgErr);
Now I want to return the values of dispparams.rgvarg out through a safe array.
Can anyone help??
-------------------------------
STDMETHODIMP CClassWrapper::RunMethod(BSTR strIIDImplemented, BSTR strClassName, BSTR strFunctionName, INT intArgCount, VARIANT * ArgType, VARIANT * ArgVals, VARIANT * ArgValsRet, VARIANT *pval)
{
HRESULT hr = S_OK; // Result code
IID ImplemInteface; // Interface to implement
CLSID clsid; // CLSID of ActiveX object.
LPDISPATCH pdisp = NULL; // IDispatch of ActiveX object.
DISPID dispid; //dispatch id of function
//get the Interface Pointer from Giud passed in
hr = IIDFromString(strIIDImplemented,&ImplemInteface);
if (FAILED(hr))
{
return hr;
}
// Retrieve CLSID from the ProgID that the user specified.
hr = CLSIDFromProgID(strClassName, &clsid);
if (FAILED(hr))
{
return hr;
}
//init com
hr = OleInitialize(NULL);
// create object
hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, ImplemInteface, reinterpret_cast<void**>(&pdisp) );
if (FAILED(hr))
{
CoUninitialize();
return hr;
}
//get id for function
hr = pdisp->GetIDsOfNames(IID_NULL,&strFunctionName,1, LOCALE_SYSTEM_DEFAULT,&dispid);
if (FAILED(hr))
{
CoUninitialize();
return hr;
}
SAFEARRAY *sa, *saTypes, *saReturn, *saDisp ;
sa = (*ArgVals->pparray);
saTypes = (*ArgType->pparray);
if(pval) ::VariantClear(pval);
DISPPARAMS dispparams = {NULL,NULL,0,0};
if (intArgCount > 0 )
{
dispparams.cArgs = intArgCount;
dispparams.cNamedArgs = 0;
dispparams.rgdispidNamedArgs = NULL;
dispparams.rgvarg = new VARIANTARG[intArgCount];
VARIANT* rgElems, *rgElemsTypes, *rgElemRets;
SafeArrayAccessData(sa, (LPVOID*)&rgElems);
SafeArrayAccessData(saTypes, (LPVOID*)&rgElemsTypes);
for(int i=intArgCount-1;i>=0;i--)
{
switch (rgElemsTypes[i].intVal)
{
case VT_UI1:
dispparams.rgvarg[i].vt = VT_UI1;
dispparams.rgvarg[i].bVal = rgElems[i].bVal;
break;
case VT_I2:
dispparams.rgvarg[i].vt = VT_I2;
dispparams.rgvarg[i].iVal = rgElems[i].iVal;
break;
case VT_I4:
dispparams.rgvarg[i].vt = VT_I4;
dispparams.rgvarg[i].lVal = rgElems[i].lVal;
break;
case VT_R4:
dispparams.rgvarg[i].vt = VT_R4;
dispparams.rgvarg[i].fltVal = rgElems[i].fltVal;
break;
case VT_BOOL:
dispparams.rgvarg[i].vt = VT_BOOL;
dispparams.rgvarg[i].boolVal = rgElems[i].boolVal;
break;
case VT_CY:
dispparams.rgvarg[i].vt = VT_CY;
dispparams.rgvarg[i].cyVal = rgElems[i].cyVal;
break;
case VT_BSTR:
dispparams.rgvarg[i].vt = VT_BSTR;
dispparams.rgvarg[i].bstrVal = rgElems[i].bstrVal;
break;
case VT_UNKNOWN:
dispparams.rgvarg[i].vt = VT_UNKNOWN;
dispparams.rgvarg[i].punkVal = rgElems[i].punkVal;
break;
case VT_DISPATCH:
dispparams.rgvarg[i].vt = VT_DISPATCH;
dispparams.rgvarg[i].pdispVal = rgElems[i].pdispVal;
break;
case VT_ARRAY:
dispparams.rgvarg[i].vt = VT_ARRAY;
dispparams.rgvarg[i].parray = rgElems[i].parray;
break;
case VT_VARIANT:
dispparams.rgvarg[i].vt = VT_VARIANT;
dispparams.rgvarg[i] = rgElems[i];
break;
default:
break;
}
}
SafeArrayUnaccessData(sa);
SafeArrayUnaccessData(saTypes);
EXCEPINFO excep;
UINT uArgErr;
hr = pdisp->Invoke(dispid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&dispparams,pval,&excep,&uArgErr);
}
else
{
EXCEPINFO excep;
UINT uArgErr;
hr = pdisp->Invoke(dispid,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&dispparams,pval,&excep,&uArgErr);
}
//release com
CoUninitialize();
return hr;
}
|
|
|
|
|
I think you lost me just a little. dispparams are the parameters you're passing in. The resulting data from calling the function is in pval, not dispparams unless I'm missing something? I can help with a little more detail and a couple examples. While I try to NEVER have to go through this like you are (I love smart pointers) I've certainly had to do it enough times.
Matt
|
|
|
|
|
I just stumbled onto this now...way cool...but under windows 95 you acn actually use interupts...?
This means low level tinkering...how much cooler can you get. However the MSDN states Window95 ONLY
Does this exclude Windows 98...? I don't see how it could...maybe the docs are really old, cuz...who uses INT anymore..?
Interupts in dos allowed crazy programming, do they apply as well in windows...?
How though...When you call INT does it actually switch the processor outta protected mode do it's thing and switch back...? I thought device drivers replaced interupts..
Anybody care to elaborate...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
You can use DeviceIoControl to do a lot of stuff that you used to use interupts in DOS for. I am not sure of the details. Some time ago I wrote an app [for Win 95/98/ME] that made INT 13h calls to read/write floppy disk sectors. I can't remember the details. I remember meaning then to write an article for CP but then forgot about it. I remember something about a vxd that worked in 98/85/ME.
For NT/2000 I had to write separate functions using CreateFile and opeing the floppy as a file. But that didnt let me access the 80th [81st one]track and we had to make some changes to the 98/ME/95 version to use the 79th [80th] track.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
So you can actually write to the boot sector of the harddisk...? Thats sweet...i'm totally gonna have to read up that...I've been thinking for sometime now...that like a
Windows Assembler would be super cool...
Just think...click n drag Visual Basic IDE but coding in assembly...I personally think it sounds cool.
I gotta learn mroe about VxD's though...I seen a really interesting book Windows 98 system programming...MSPRESS every read it...?
In any case...i'm pretty hapy even though it'll be sometime before i have time to dick around with those functions.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hi.. just wanna ask a simple question..
given the LOGFONT data structure.. how would I know the FONT SIZE of the TEXT displayed..'cuz seems like lfHeight and lfWidth need to be transformed or processed to get the FONT SIZE?
Thanks in advance!!!
|
|
|
|
|
Initialize the structure with a call to GetTextMetrics(ex)
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
The relation between lfHeight and the font's point size is:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
How do I programmatically rename a file?
Cd
|
|
|
|
|
CFile::Rename would probably do wonders
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Check:
rename, _wrename
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
You can use the MoveFile API call.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
I have a requirement by which my application should run in two modes
1) As a back ground process taking inputs as a command line arguments
2) As a stand alone GUI application with dialogs etc stuff.
So how to go about it?
It should be developed in VC++ on NT
1) Is it wise to develop the product as two applications? One application will be providing only GUI functionality and
the other doing the core job?
or
2) Develop a single application which runs with GUI if there is no command line argument and works in
background if data is fed as command line arguments.
Can any one share some experiences?
|
|
|
|
|
I would suggest parsing the commandline in a single application. Well designed classes would allow code reuse, minus the GUI code.
I've never written an app that required console/plus windows if thats your desired effect. However I have developed an app that parsed the Cmdline and decided whether to show windows or just go abouts doing it business.
I'd go with one module, not two...just my opinion though.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I recently had to do something like this.
I wrote a console app that would take command line options and could be run on its own.
I then made a dialog app that would generate the command line string and use a call to CreateProcess to run the console application.
Doing it this way simplified the process cuz I only had to write the guts of the program once for the console app. The GUI was just a front-end app to convert user input to a command line string yet would produce the same output.
Josh Knox
that-guy.net
"Before you criticize someone, walk a mile in their shoes. That way, when you criticize them, you're a mile away, and you have their shoes." - author unknown
|
|
|
|
|
Hi folks!
I just start to go crazy. I had to convert an Word-Document in an AFP-Document for an HOST-System. I can´t use the MFC and I also had to use an IBM Printer Driver for the convertion .doc to .afp.
I wanna use the OpenPrinter()- and SetPrinter()-methods because the user should not see an printing dialog and the IBM printing driver is not the standard printer.
My OpenPrinter()-Call always fails, the return value is zero. When I check the LastError-Code it´s 87 (The parameter is incorrect.).
Is there anybody out there who can help me? What is my mistake? Thanks a lot for any help or suggestion!
cu,
Lars
|
|
|
|
|
- What name are you passing in?
- Where did you get the name? Did you hard code it or enum installed printers?
- Does this work when you do it manually; i.e. open the document in word, select print from the file menu, select the printer, print?
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
Hi, Shog9!
I tried every printer name I could find ("friendly" name, shared name, etc). For testing I coded the printer name hard, maybe I should try EnumPrinters() (got this tip just a few minutes before...).
Can´t proof it manually ´cause the printer driver is "installed" at the "FILE"-port, ´cause I don´t wanna print "real". I just wanna use this driver to convert a .doc-File to an .afp-File. After convertion, I´ll transport the afp-File to a HOST system.
Thanks for trying helping me!!!
cu,
Lars
|
|
|
|
|
I have made a smart edit control class called CStringEdit that is subclassed off the CEdit class. This control works very nicely for me when I include it as a member variable control in a Dialog class. The purpose of this control is to let me have a lot more run time control over a users data entry in a dialog edit box.
The CStringEdit class has interfaces to perform these functions:
void SetFixedLen(BOOL bFixedLen) ... used to set the string to fixed length padded if necessary to the right at the call to GetText(). Defaults to FALSE.
void SetMaxLength(int nMax) ... used to set the maximum string length. The default value of zero means no length restriction and FixedWidth feature is ignored.
void SetLegal(LPCSTR lpszLegal) ... used to enter a string of characters that are legal in the edit box. Defaults to NULL string which means that all characters are legal.
void SetIllegal(LPCSTR lpszIllegal) ... used to put in a string of characters that are specifically illegal in the editbox. Defaults a NULL string such that there are no illegal characters.
void SetText(LPCSTR lpszText) ... used to send intial text to the edit box.
void GetText(CString& strText) ... used to get back out the edited text string.
This control class uses a connection that I setup with the ClassWizard on the OnUpdate() message to validate the edit box contents at each instance that the control thinks there has been a change to the text content and it thinks it is time to re-display the control contents. In this event routine I do the validation to limit the string length and verify if the string contents are valid. It works just dandy!!!
NOW FOR MY PROBLEM.......
I have a particular instance of this control in a dialog where there needs to be some additional real time validation of the edit box content that is dependent upon other things on that same dialog. I have tried to connect the specific instance of this edit control member variable to its own OnUpdate() procedure in the dialog class. Once again this cinnection was mapped using the Class Wizard. My problem is that the event procedure is never being invoked.
Can anyone help me figure out why this does not work?? I can send the whole class source code plugged into a simple demo app if my write-up here is not complete enough....
Thanks from a new VC++ 6 user.
Mike
|
|
|
|
|
I sort of lost you in the last paragraph where you have defined your problem. Are you trying to call a message handler function through direct function call ? If this being the problem then rather than calling the function directly - you must use PostMessage() (see MSDN help on PostMessage() ) to invoke the event handler. PostMessage() a parameter that contains the MESSAGE_ID, LPARAM, and WPARAM
If i incorrectly understood the problem then can you please elaborate it further
-cheers
-kashif manzoor
peace to all
|
|
|
|
|
Your problem is that you have two OnUpdate s, one in CStringEdit and one in the parent dialog, and the latter handler is not being called, right?
If so, then the solution goes as follows:- In
StringEdit.h , change
afx_msg void OnUpdate(); to
afx_msg BOOL OnUpdate(); Do the necessary modifications on the .cpp as well, and have this handler return FALSE .
- In
StringEdit.cpp , replace
ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate) with
ON_CONTROL_REFLECT_EX(EN_UPDATE, OnUpdate) That should do it. The changes indicate the framework that the reflection handler of CStringEdit allows further processing by the parent (by returning FALSE instead of TRUE as the code for ON_CONTROL_REFLECT does internally).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|