|
The CLSID, which should be recorded in the typelib somewhere.
I prefer using #import, which exposes the whole of a type-lib, including the CLSIDs.
Here's an example - I'm using Excel's _Application class (it's a COM class - you could use it via MFC's 'Add Class' route:
#import "libid:00020813-0000-0000-C000-000000000046" version("1.6") auto_search no_dual_interfaces rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB") rename("DocumentProperties", "excelDocumentProperties") rename("SearchPath", "excelSearchPath") rename("CopyFile", "excelCopyFile") rename("ReplaceText", "excelReplaceText")
int main(int, char**)
{
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
{
Excel::_ApplicationPtr xl;
if (SUCCEEDED(xl.GetActiveObject(__uuidof(Excel::Application))))
{
std::cout << "Getting name\n";
std::cout << xl->ActiveWorkbook->FullName << std::endl;
}
}
CoUninitialize();
}
If you're using VC6 (which I'm guessing you are?), I'm not sure how well #import will work for you, though
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am trying to convert wchar[] content to byte[]... but to my surprise, all the suggested methods went in vain..
i used widechartomultibyte,wcstomobs .... they all reproduced "???" marks instead of characters, when i use Chinese or japanese content..
can anyone help me how to convert content without any loss??
Aim: my objective is to read byte by byte of wchar[] content and convert it to byte[]..
i'd be graterful to your reply.
Thanks,
Rajesh.
|
|
|
|
|
You can allocate byte array and copy the data using memcpy. if you're using chinese or japanese characters it's hard to keep in single byte format. wchar_t is two byte so you may need to allocate 2* actual wchar elements to contain everything in the byte array. What is the purpose after converting to a byte array?
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
I suppose you are the same guy as Rakesh5 that posted this question yesterday ? (Why do you create multiple accounts ?)
RajeshRPR wrote: they all reproduced "???" marks instead of characters,
David asked you yesterday where these characters are displayed. Are you inspecting the byte array with your debugger ? If yes, then it is normal that the characters are not displayed properly, because the debugger inspects an array of unsigned chars and not a string.
|
|
|
|
|
Hey Cedric,
I am his friend..We are working together.. i dont know he posted anything like that.. Hence, i posted today.
Have you replied him anything?
Thanks,
Rajesh
|
|
|
|
|
RajeshRPR wrote: can anyone help me how to convert content without any loss??
There is no conversion between Chinese or Japanese and the ANSI code page. If you need to retain the contents and use it as a multibyte string you will need to convert it to UTF8. You can do this by using CP_UTF8 instead of CP_ACP when calling WideCharToMultiByte().
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|
I developed an application by using Visual Studio 2005 (Visual C++/MFC based project). The developed exe works fine over the machine that already have installation of Visual Studio 2005. But it does not run over other machine. I even installed the .net2 frameowrk and service pack of .net2 framework as well but did not succdeed in running the application.
I remember that in old days, there was an option of static compilation in Visual C++ (6 version) without .net framework. So how we can do the same in Visual Studio 2005 that is dependant over .net framework. In static compilation, the compiler/linker put all the dependant stuff in exe file.
Please guide me how I can run the application over machines that does not have installation of Visual Studio 2005.
THANKS.
|
|
|
|
|
Madhu_Rani wrote: Please guide me how I can run the application over machines that does not have installation of Visual Studio 2005.
Dynamic linked Visual Studio 2005 C++ applications may require the C run-time and MFC libraries installed on the client machine.
Microsoft Visual C++ 2005 Redistributable Package (x86)[^]
Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)[^]
Another option is to static link your project by choosing 'Use MFC in a Static Library' in the General section of your configuration properties. You will also need to choose '/MT' runtime library in the Code Generation section.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
Is it possible to change the height of titlebar of all Dialogs which are used only in my application using WM_NCCALCSIZE or DrawCaption() ..if yes please suggest me any sample which does the same....
|
|
|
|
|
|
|
Using C++ 6.0
I have a list control CListCtrl and am doing inplace edit and is working fine but I need to trap keyboard input using PreTranslateMessage and in this method I need to determine if the List item is currently being edited.
Any help appreciated,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
You can listen for the LVN_BEGINLABELEDIT/LVN_ENDLABELEDIT pair, or use LVM_GETEDITCONTROL.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|
|
Duh, why didn't I think of that?
Good Eye, thanks
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
i have an Explorer context menu extension. it works in Vista and XP, Win32 and x64 without problem - as long as you're right-clicking from within Explorer. it uses IContextMenu3 and IShellExtInit.
in Win32, you can also right-click and use the extension from within any common file open dialog (ex. CFileDialog - yes, using the new-style dialogs). but in Vista 64 and XP 64, my extension doesn't show up in the file open dialog. again, it all works fine from plain old Explorer (desktop, My Computer, an official Explorer window, etc.).
so, it looks like the common file dialog's context menu is doing something slightly different in x64. but i can't find any reference to any such changes...
anyone else run into this ?
|
|
|
|
|
Chris Losinger wrote: anyone else run into this ?
Hi Chris,
I have recently started using Windows7 x64 as my development box and I am also experiencing problems with Explorer context menu extensions that worked fine on 32 bit XP. My extensions simply do not appear... I have not spent any time researching the cause of the issue. If you figure it out before I do post your results here. I'll do the same.
Best Wishes,
-David Delaune
|
|
|
|
|
if they don't appear at all, you probably need to tweak your defn of GetCommandString. it changed in x64.
#ifdef _WIN64
STDMETHOD(GetCommandString)(UINT_PTR, UINT, UINT*, LPSTR, UINT);
#else
STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT);
#endif
but that won't fix the file dialog issue i'm having.
|
|
|
|
|
I've been using XP x64 for a while and I noticed some odd context menu behaviour from some programs - like only appearing in the 32bit Explorer, but I never really looked into it, and this seems to be something different anyway, so I have no real answer for you (sorry!)
|
|
|
|
|
HDC hdcPrinter;
OpenPrinter(pn, &hdcPrinter, NULL);
I get a compile error on arg 2 &hdcprinter which says invalid conversion from HDC to Void I am using the compiler Dev-C++
What is wrong. All examples have seen show that this should work,
|
|
|
|
|
Could you please provide:
- The exact error message (copy/paste)
- The type of hdcPrinter
|
|
|
|
|
the printer is HP Photosmart C7100 series which is pointed to by pn
hdcPrinter is declared as HDC hdcprinter.
Copy & paste doesn't work in the compiler window I will try and type it.
In function 'BOOL SavePrintFile(HWND_*,HDC_)'.
invalid conversion from 'HDC_ **'to 'void**'
initilizing argument2 of 'BOOL OpenPrinterA(CHAR*,void**,_PRINTER_DEFAULTSA)'
[Build Error] [maingfa.o] Error 1
|
|
|
|
|
The OpenPrinter Function[^] expects the second argument to be a HANDLE not an HDC.
Here is an example of using OpenPrinter to open the default printer using the GetDefaultPrinter Function[^]
#include <Winspool.h>
HANDLE OpenDefaultPrinter(ACCESS_MASK dwMask)
{
HANDLE hPrinter = INVALID_HANDLE_VALUE;
PRINTER_DEFAULTS pDef = {0};
DWORD dwSize;
GetDefaultPrinter(NULL, &dwSize);
TCHAR* szBuffer = (TCHAR *)alloca(sizeof(TCHAR) * dwSize);
if(NULL != szBuffer)
{
if(GetDefaultPrinter(szBuffer, &dwSize))
{
pDef.DesiredAccess = dwMask;
OpenPrinter(szBuffer, &hPrinter, &pDef);
}
}
return hPrinter;
}
OpenDefaultPrinter(PRINTER_ALL_ACCESS);
Best Wishes,
-David Delaune
[UPDATE]
You should remove my call to alloca and use heap-based memory allocation with the new/delete operators. My personal projects usually have structured exception handler for stack overflows and I inadvertently used alloca in this comment.
modified on Tuesday, August 11, 2009 4:46 PM
|
|
|
|
|
Hi,
Below is the line of code(C++) for Reading the Textfile line by line.
CString = strFilePath; // text path file path
ifstream Textfile;
Textfile.open(strFilePath,ios::in);
std::string value;
while(!Textfile.eof())
{
getline(Textfile,value); // Read line by line...
}
Textfile.close();
Now the question is I am having 40MB text file size. I need to read 1000 Lines in a single shot (And upto read 1000 times to reach the whole 40 MB size) not line by line. How to do this?
(ie from 1 to 1000 and 1001 to 2000.... reach max lines)
reg,
Subbu
|
|
|
|
|
To read a line from a file, you effectively need to read the file character by character - that's how you find the line termninator character.
Sounds to me like you'd be better off memory mapping the whole file and processing it in memory
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
spalanivel wrote: How to do this?
You can't. You can, however, reduce file I/O by reading the entire file once into a buffer and then process that buffer instead. See Stuart's suggestion.
"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
|
|
|
|