|
How do I pass MySQL connection ID to COM using VC++ 9.0?
At the moment I have to pass the host, username, pwd, and db name to the COM but make a new connnection there. I want to pass the connection ID but I am unable to shoehorn a variable of type MYSQL into an acceptable parameter.
GER
Ger
|
|
|
|
|
Hi,
I have a VS 6.0 (visual basic) add-in for Outlook that I wrote for Outlook 2002 (XP). It is a useful add in that I wish (or maybe not, LOL) to modify to support Outlook 2003 & 2007. I have Visual Studio 2008 Pro installed along with Office 2003.
Using the VSTO add-in templates, I wanted to create a simple 'Hello' add-in and ensure that it works and then test it on a client install (a machine not running any development tools). At first I thought this would be easy, but find my asking Why is it so difficult to create a simple add-in and have it work.
The built-in VSTO addin templates seem to force .NET, which has many pre-requisites and all kinds of stuff.
My first question to the Code Project World, <u>is it better to use templates or create Addin using C++ and COM without .NET? </u>
I did write a simple 'Hello' using C++/COM without .NET, which produces a <i>Clean</i> .dll that registers as add-in. Where the .NET solution has manifest and .NET security policy assembly difficulties. Plus .NET is not required and do not want to force clients to install All this extra Baggage for what should be a simple addin.
Thanks to code found here on CodeProject, I was able to get this far, but am at a crossroad now. I appreciate any comments from the experts.
Aloha, Mike
|
|
|
|
|
Hi,
I am using CLSID_MMDeviceEnumerator for creating the instance of MMDeviceEnumerator.However,the call CoCreateInstance is failing saying the class is not registered.Upon checking the CLSIDs in the registry,i found that its not there in registry.
What to do?
The below code is taken from MSDN.
// soundcard.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<atlbase.h>
//#include "Winerror.h"
#include "Mmdeviceapi.h"
#include "Functiondiscoverykeys_devpkey.h"
//-----------------------------------------------------------
// This function enumerates all active (plugged in) audio
// rendering endpoint devices. It prints the friendly name
// and endpoint ID string of each endpoint device.
//-----------------------------------------------------------
#define EXIT_ON_ERROR(hres) \
if (FAILED(hres)) { goto Exit; }
#define SAFE_RELEASE(punk) \
if ((punk) != NULL) \
{ (punk)->Release(); (punk) = NULL; }
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
void PrintEndpointNames()
{
HRESULT hr = S_OK;
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDeviceCollection *pCollection = NULL;
IMMDevice *pEndpoint = NULL;
IPropertyStore *pProps = NULL;
LPWSTR pwszID = NULL;
hr = CoCreateInstance(
CLSID_MMDeviceEnumerator, NULL,
CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator,
(void**)&pEnumerator);
EXIT_ON_ERROR(hr)
hr = pEnumerator->EnumAudioEndpoints(
eRender, DEVICE_STATE_ACTIVE,
&pCollection);
EXIT_ON_ERROR(hr)
UINT count;
hr = pCollection->GetCount(&count);
EXIT_ON_ERROR(hr)
if (count == 0)
{
printf("No endpoints found.\n");
}
// Each loop prints the name of an endpoint device.
for (ULONG i = 0; i < count; i++)
{
// Get pointer to endpoint number i.
hr = pCollection->Item(i, &pEndpoint);
EXIT_ON_ERROR(hr)
// Get the endpoint ID string.
hr = pEndpoint->GetId(&pwszID);
EXIT_ON_ERROR(hr)
hr = pEndpoint->OpenPropertyStore(
STGM_READ, &pProps);
EXIT_ON_ERROR(hr)
PROPVARIANT varName;
// Initialize container for property value.
PropVariantInit(&varName);
// Get the endpoint's friendly-name property.
hr = pProps->GetValue(
PKEY_Device_FriendlyName, &varName);
EXIT_ON_ERROR(hr)
// Print endpoint friendly name and endpoint ID.
printf("Endpoint %d: \"%S\" (%S)\n",
i, varName.pwszVal, pwszID);
CoTaskMemFree(pwszID);
pwszID = NULL;
PropVariantClear(&varName);
SAFE_RELEASE(pProps)
SAFE_RELEASE(pEndpoint)
}
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
return;
Exit:
printf("Error!\n");
CoTaskMemFree(pwszID);
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
SAFE_RELEASE(pEndpoint)
SAFE_RELEASE(pProps)
}
int _tmain(int argc, _TCHAR* argv[])
{ HRESULT hr=CoInitialize(NULL);
PrintEndpointNames();
::CoUninitialize();
return 0;
}
|
|
|
|
|
Hello,
I am trying to find some examples and information on how to add COM to the C# application and connect to a COM server that was created with C++. Any help would be wonderful.
Thanks
|
|
|
|
|
|
Hello.
I was wondering if it is possible to get a COM pointer to a running instance of Yahoo Messenger.
I have tried several methods but got stuck due to the fact that I am kind of a noob when it comes to COM.
The best I managed is to create a instance of Yahoo! Messenger via COM from my app.
In order to run multiple instances of Yahoo! Messenger you need to set<br />
[HKEY_CURRENT_USER\Software\yahoo\pager\Test]<br />
"Plural"=dword:00000001
I apologize if my question is with obvious answer/stupid/dumb.
Thanks in advance.
|
|
|
|
|
Hi,
I need to pass MFC Class "CStringArray" as Parameter in my exposed method in com component.
When I Compile I get 2 errors
1)#error MFC requires C++ compilation (use a .cpp suffix)
2)command line error MIDL1003 : error returned by the C preprocessor (2)midl
Can Anybody suggest me how to go about it?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
Hi,
I m using OWC11 with ASP, Trying to draw simple Bar graph using data from SQL database, i managed to draw the chart but i also have an extra chart(to the right) with it. Please let me know how to get rid of it.
here is the piece of code that does the charting
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open strSQLStatement, objADODB, 1
'Response.Write("The value of " & strColName & "=" & objRS1(0))
set objCSpace = Server.CreateObject("OWC11.ChartSpace")
'set up chart and properties
set objChart = objCSpace.Charts.Add(0)
set objConstants = objCSpace.Constants
'create a clustered column chart
objChart.Type = objConstants.chChartTypeColumn3D
'add a legend
objChart.HasLegend = False
'objChart.ShowFilterHeaders = False
set objCSpace.DataSource = objRS1
objCSpace.HasMultipleCharts = False
objCSpace.HasChartSpaceLegend = False
objCSpace.HasChartSpaceTitle = False
objCSpace.DisplayFieldButtons = false
objCSpace.MinorVersion =
'set the data points and categories
'objChart.SetData objConstants.chDimSeriesNames, 0, "age"
objChart.SetData objConstants.chDimCategories, 0, "Level"
objChart.SetData objConstants.chDimValues, 0, "NOF"
'set up some additional properties
'add and format the chart title
objChart.HasTitle = True
objChart.Title.Caption = "TICS Summary"
set objFont = objChart.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 10
objFont.Bold = True
'add and format a title to the category axis
set objAxis = objChart.Axes(objConstants.chAxisPositionBottom)
objAxis.HasTitle = True
objAxis.Title.Caption = "TICS Levels"
set objFont = objAxis.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 8
objFont.Bold = True
'add and format a title to the value axis
set objAxis = objChart.Axes(objConstants.chAxisPositionLeft)
objAxis.HasTitle = True
objAxis.Title.Caption = "No. Of Files"
set objFont = objAxis.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 8
objFont.Bold = True
'Save the current chart to a GIF file with a temporary
'filename using the FSO
set fso = Server.CreateObject("Scripting.FileSystemObject")
strFileName = fso.GetTempName()
GifFileName = strFileName
strFileName = Server.MapPath(".") & "\" & strFileName
RenName = strFileName
RenName = replace (RenName, ".tmp", ".gif")
'Response.Write(GifFileName)
GifFileName = replace (GifFileName, ".tmp", ".gif")
objCSpace.ExportPicture RenName, "gif", 800, 400
'fso.MoveFile strFileName,GifFileName
Response.Write("<img src=" & GifFileName & ">")
'Use On Error Resume Next to make sure we eventually delete
'the temporary GIF file even if something fails in the next
'couple of functions
on error resume next
'The GIF file has been created. Return the contents of the
'GIF file as binary data using the BinaryFileStream COM object
set objBinaryFile = Server.CreateObject("BinaryFileStream.Object")
Response.BinaryWrite objBinaryFile.GetFileBytes(CStr(strFileName))
'Delete the GIF file since it is no longer needed
objBinaryFile.DeleteFile CStr(RenName)
'clear variables
set objBinaryFile = nothing
set FSO = nothing
set objCSpace = nothing
</img>
Please Help!!!
|
|
|
|
|
Hello!
My name is Alla. I'w working as a programmer in New Hampshire. I've just started doing Word and Powerpoint Automation (never done before Office Automation). The application I'm working on now creates document-packages,containing one or more Word documents and export these documents to particular locations.
I created Word Application Instance only once at the beginning, so I use this Instance for all documents that I'm going to create for exporting. Everything was fine so far, but when I'm trying to export a huge amount of documents,the following error appears - RPC SERVER UNAVAILABLE and any reference to existing Word Instance throws an error ( it happens when during processing some documents for some reason Range.Paste method throws an exception (RPC server failed)., then I get MS Word warning message and Word trying to recover documents. Immediately after that I get RPC SERVER UNAVAILABLE - means that any access to my Word Instance fails. May be it makes sense to create many Word Application Instances for each document, but we have problem with performance.I tried to send this question to microsoft forums, but nobody responded..Could you, please, help me to solve this problem?
Thank you very much in advance and best regards.
Alla
|
|
|
|
|
Hey How did you resolve this?
|
|
|
|
|
Hello!
My name is Alla. I'w working as a programmer in New Hampshire. I've just started doing Word and Powerpoint Automation (never done before Office Automation). The application I'm working on now creates document-packages,containing one or more Word documents and export these documents to particular locations.
I created Word Application Instance only once at the beginning, so I use this Instance for all documents that I'm going to create for exporting. Everything was fine so far, but when I'm trying to export a huge amount of documents,the following error appears - RPC SERVER UNAVAILABLE and any reference to existing Word Instance throws an error ( it happens when during processing some documents for some reason Range.Paste method throws an exception (RPC server failed)., then I get MS Word warning message and Word trying to recover documents. Immediately after that I get RPC SERVER UNAVAILABLE - means that any access to my Word Instance fails. May be it makes sense to create many Word Application Instances for each document, but we have problem with performance.I tried to send this question to microsoft forums, but nobody responded..Could you, please, help me to solve this problem?
Thank you very much in advance and best regards.
Alla
|
|
|
|
|
Hi,
My application working fine in the dev environment.But in the testing /production environment
it is not working because that environment has only
windows server 2003
IIS
I have prepared a MSI which will automatically install .net2.0 framework
In my application I have Used some microsoft VC++ dll's also along with .net dll's.
Now Iam getting "RUNTime Error" pop-up screen message as below
" The Application has been terminated in an Unusual Way"
On googling i came to know that some dll's like msvcrt.dll of windows server 2003 has to be changed...But Iam not pretty sure about it..
In Production/test environment there is only framework installed ,but there is no visual studio installed on it.may be due that this error may occur...
So kindly post your suggestions and views to help me
|
|
|
|
|
Hi,
Need help in Synchronizing Execution of Multiple Threads in VC++, i am new to Multithreading Programming.. Any related book or documents will be useful.
Regards,
KDevloper
modified on Saturday, October 4, 2008 12:25 AM
|
|
|
|
|
Hi,
Go through the following article, that will give you some idea about Multithreading programming using Visual Basic.
Article1[^]
Artcle2[^]
Article3[^]
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Thanks John, Am sorry to mention that i need Multithreading programming using Visual c++.
Regards,
KDevloper
|
|
|
|
|
I have already download the sourcecode of Transparent Flash Control
http://www.codeproject.com/KB/COM/flashcontrol.aspx
now I want to draw something on the flash control, I do it like this
OLECONTAINER(void)::Draw(HDC hdcDraw, const RECT *rcDraw, BOOL bErase)
{
HWND hwnd = GetHWND();
HRESULT hr;
RECT r;
IOleObject *lpO = m_lpO;
IViewObject *lpV = m_lpViewObjectEx ? (IViewObject
*)m_lpViewObjectEx : m_lpViewObject;
// if (!m_bTransparent)
{
RECT rTotal;
::GetClientRect(hwnd, &rTotal);
if (lpV)
{
if (!hdcDraw)
{
hdcDraw = ::GetDC(hwnd);
hr = OleDraw(lpV, DVASPECT_CONTENT, hdcDraw, &rTotal);
::ReleaseDC(hwnd, hdcDraw);
}
else
{
hr = OleDraw(lpV, DVASPECT_CONTENT, hdcDraw, &rTotal);
}
}
TextOut(hdcDraw, 0, 0, "test", 4); // <======= do it like this
return;
}
But I find that the text drawn on the hdc will always be covered drawn by flash control
how can I do it?
|
|
|
|
|
Hi all
I have to Create a DLL dynamically in C#. I dont know how Can i Create it dynamicaaly. Can anyone tell me the solution for this.
Thanks in advance
sri
|
|
|
|
|
What aspect of the C++ language makes it easily adapted to COM application
|
|
|
|
|
For VC++'s implementation of C++ : it's the v-table.
- Bio.
|
|
|
|
|
In c++ you got ATL wich is a good way for developing COM objects
JO
|
|
|
|
|
C++ suport Pointer virtual mechanishm(Vtable),that ascpect will more help to develop COM application with efficent resource uses.
|
|
|
|
|
I’m using idl file to create COM Type Library,
Here is the idl:
import "oaidl.idl";
import "ocidl.idl";
[
uuid(71050F79-3FC6-4BCA-BC36-A79465500B71),
version(1.0),
helpstring("MyProj 1.0 Type Library")
]
library MyProjLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("..\Interfaces\Interfaces.tlb");
[
uuid(83BC908B-C13C-4D6A-B290-C97057ACEBC4),
helpstring("MyClass Class")
]
coclass MyClass
{
[default] interface IMyProjMessage;
};
};
In another project, I call the library with:
#import "..\..\MyProj\MyProj.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
Here’s the error I've got:
fatal error C1084: Cannot read type library file: '..\..\MyProj\MyProj.tlb': Error loading type library/DLL.
I am newer for com & activeX controls – can someone help me?
Many thanks,
S
|
|
|
|
|
Hello Sara123,
Make sure that any dependency TLB(s) (e.g. ..\Interfaces\Interfaces.tlb) is/are either registered, or it/they is/are in a path that is discoverable by the compiler (e.g. in the same directory as MyProj.tlb).
Hope this helps,
- Bio.
|
|
|
|
|
thank you so much of your briefly answer!
S
|
|
|
|
|
Hello Sara123,
No problem. But is your problem solved ? I suggest that your various dependency type libraries be registered. This way, the compiler will be able to refer to them when necessary.
- Bio.
|
|
|
|
|