|
hi shailesh,
there is book called inside COM by dale rogerson.
it's a good book for COM learner
all the best
|
|
|
|
|
Hi
can anyone help me finding a book about developing "com add-in" for office applications using mfc ?
thanks alot
Tarek
|
|
|
|
|
This is what I'm trying to do. I'm trying to write a DLL that will give me access to COM components that are available from an Off-The-Shelf product (Sherlock32) so I can get information from it while it is running. I've seen a lot of examples of how to write stand-alone code but I'm lost as to how to handle everything properly.
Now if I understand things I can use:
#import "c:\sherlock\bin\sp32.exe" named_guids no_namespace
in my header file to get access to the CSLID (CSLID_Sherlock) which was put in the exe.
Then I can use the following code to get access to the various features.
ISherlockPtr m_Sherlock;
CoInitialize(NULL);
m_Sherlock->CreateInstance(CSLID_Sherlock);
m_Sherlock->function;
CoUnitialize();
I'm I at least headed in the correct direction? I know I need to add some error checking to make sure the instance was created and the function is returning the correct stuff. One big question I have is should I create the instance once and hold on to it for the length of the use of the DLL or should I create and release it every time I want access to the functions?
[Side note: For those of you that are thinking why don't I just put my access code in the program that needs access to Sherlock here is the reason. The DLL is going to be used by a scripting program/language that has DLL capabilities but not COM.]
Thanks,
George
-- modified at 8:54 Friday 5th October, 2007
|
|
|
|
|
I had to google Sherlock32 to get an idea of what it was. You provide very little useful information.
But, if the executable or DLL that you are interested in is written in a way that it can act as a server for a COM class (this is not a requirement), it has to register its CLSID. Read this: COM Class Objects and CLSIDs[^]
The simplest approach is to call: CoCreateInstance[^]
Are you doing this in .NET? You gave no clue.
-- modified at 19:31 Thursday 4th October, 2007
|
|
|
|
|
Sorry for the lack of information but I was just trying to get a feel for whether my approach is correct and didn't realize you needed more information about Sherlock32. From what I understand about it it does run as a COM server and it has some functions available under its COMM server that should allow me to control it and get information from it. I'll take a look at the things you suggested.
I'm using Visual Studio C++ 6.0 to write my code and sticking with C++ & MFC for my coding. They haven't converted over to using .NET at my office yet.
Thanks,
George
|
|
|
|
|
Who know what the meaning of error code 269 ? I can't find it anywhere.
|
|
|
|
|
Hello,
Error 269 means that ReferenceBind is invalid. Reference name is missing.
I hope this helps.
Have a nice day.
Regards,
James Smith
James Smith
www.componentone.com
|
|
|
|
|
In which scenerios We can use Windows Service.
Can any body expling what is the purpose of windows services.
As windows service is continious running process.
Can we built windows service with out timer control? If Yes then please give a sample how.
Thanks in Advance
Chandra.Anumakonda
|
|
|
|
|
is a driver (sys file) a com program?
Zo.Naderi-Iran
|
|
|
|
|
I suppose it is possible, but that would be ridiculous for a device driver.
Most drivers are written in C or assembly. Typically, drivers are linked together in an operational stack, that is not COM-derived or dependent on the COM library. See the MSDN Kernel Architecture Design Reference[^] to get an idea of what types of system structures are required for Drivers. Its an entirely different world.
Programmers have been known to write kernel drivers to gain access to kernel mode data structures, as this is the only way to add user code to the operating system.
-- modified at 18:40 Thursday 4th October, 2007
|
|
|
|
|
Hi,
I have Simple ActiveX dll for opening connection to the database
and execute a stored procedure which returns a RecordSet.
I added it to the Component Services as a COM component
I spawned 10 threads to create object for COM and called the
method defined in the COM dll in Serialized Transaction support
and in ReadCommitted support.
I didnt notice any diffence in the execution time of the stored
procedure in both the cases.
What may be the reason?
With Thanks
Sakthi
|
|
|
|
|
Hi All:
I was trying to Used Distributed Transaction with Thread to allow many
Inserting operations into Different Databases in Different Server at the same
time
My Question is can we applying the Distributed Transaction and Threading
Together.
I try to apply it But the folowing Problem appeares through Open the first
Database Connection
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in mscorlib.dll
Additional information: The component is configured to use synchronization
and this method call would cause a deadlock to occur.
' Some oF My The Code
Private strDBQA As String = "Data Source=QASRV; Initial Catalog=employee;
Password=sasa; User ID=sa"
Private strDBFA As String = "Data Source=FADI; Initial Catalog=Employee;
Password=sasa; User ID=sa" 'Enlist =false"
Private _Itransaction As System.EnterpriseServices.ITransaction
Private _boolQ As Boolean = False
Private _boolF As Boolean = False
Public ReadOnly Property PITransaction()
Get
Return _Itransaction
End Get
End Property
'The Main Function
Function TestThread(ByRef strError As String)
Try
_Itransaction = System.EnterpriseServices.ContextUtil.Transaction
Dim objThread As System.Threading.Thread
objThread = New System.Threading.Thread(AddressOf QServer)
objThread.Start()
objThread = New System.Threading.Thread(AddressOf Fserver)
objThread.Start()
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
strError = "Completed"
End If
Catch ex As Exception
ContextUtil.SetAbort()
strError = ex.Message
Catch ex As Exception
End Try
Private Sub QServer()
Try
Dim oConnectionQ As New SqlClient.SqlConnection
Dim cmdSql As New SqlClient.SqlCommand
oConnectionQ .ConnectionString = strDBQA
oConnectionQ .Open()
oConnectionQ .EnlistDistributedTransaction(PITransaction)
cmdSql.Connection = oConnectionQ
cmdSql.CommandText = "update Test set ID = ID + 10"
cmdSql.ExecuteNonQuery()
_boolQ = True
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
End If
Catch ex As Exception
ContextUtil.SetAbort()
End Try
End Sub
Private Sub Fserver()
Try
Dim oConnectionF As New SqlClient.SqlConnection
Dim cmdSql2 As New SqlClient.SqlCommand
oConnectionF .ConnectionString = strDBFA
'================
' in the strF oPen The Error Appear
oConnectionF .Open()
oConnectionF .EnlistDistributedTransaction(PITransaction)
cmdSql2.Connection = oConnectionF
cmdSql2.CommandText = "update Test set ID = ID + 10"
cmdSql2.ExecuteNonQuery()
_boolF = True
If _boolF = True AndAlso _boolQ = True Then
ContextUtil.SetComplete()
End If
Catch ex As Exception
ContextUtil.SetAbort()
End Try
End Sub
F.mathkour
|
|
|
|
|
|
Can i save array of int values into attribute using put_value method????
Because i have some problem with this. It save only first element of array.
Maybe i have some error in my code,
int *arr = new int[ 5 ];
for( int i = 0 ; i < 5 ; i++ )
arr[ i ] = i;
VARIANT var;
var.vt = VT_BYREF|VT_INT;
var.pintVal = &arr[0];
hr = spXMLDOMAttribute->put_value( var );
|
|
|
|
|
vippavlo wrote: Can i save array of int values into attribute using put_value method????
Because i have some problem with this. It save only first element of array.
Maybe i have some error in my code,
int *arr = new int[ 5 ];
for( int i = 0 ; i < 5 ; i++ )
arr[ i ] = i;
VARIANT var;
var.vt = VT_BYREF|VT_INT;
var.pintVal = &arr[0];
hr = spXMLDOMAttribute->put_value( var );
I don't think you can just save an array to an attribute, but I do know that VT_BYREF doesn't make it an array. If this were to work at all, you would have to create a SAFEARRAY and make a variant of type VT_ARRAY | VT_INT
Nathan
|
|
|
|
|
Thanks for answer))) i found some info about this and now i know that i should be use SAFEARRAY.))
Sory for some grammar mistakes. I'm from Ukraine and don't know Enlish perfect
-- modified at 18:09 Monday 24th September, 2007
ISQ 469907496
|
|
|
|
|
Do you know exactly that SAFEARRAY will be stored correct in attribute???
Because i have a problem when i put value into attribute: "Type mismatch". What it mean??? May be i create SAFEARRAY uncorrect???? If you have some example for putting CComSafeArray into CComVariant, please give me, i'll be much obliged to you.
ISQ 469907496
|
|
|
|
|
vippavlo wrote: Do you know exactly that SAFEARRAY will be stored correct in attribute???
Because i have a problem when i put value into attribute: "Type mismatch". What it mean??? May be i create SAFEARRAY uncorrect???? If you have some example for putting CComSafeArray into CComVariant, please give me, i'll be much obliged to you.
I believe I mentioned in my last reply that you probably can't store an array in an XML attribute. Type mismatch is the error I'd expect if it wasn't allowed. You can probably define your own method to convert the array to and from a string, since string is the real type of the attribute anyway. While I'd just drop SAFEARRAYs for what you are doing, I've found an example of creating a SAFEARRAY in the MSDN documentation:
SAFEARRAYBOUND sab;
sab.cElements = 2;
sab.lLbound = 0;
hresult hr;
SAFEARRAY * pSa;
pSa = SafeArrayCreateEx(VT_RECORD, 1, &sab, pRecInfo);
if (pSa == NULL)
return E_OUTOFMEMORY;
PVOID pvData;
hr = SafeArrayAccessData(pSa, &pvData);
if (FAILED(hr)) {
SafeArrayDestroy(pSa);
return hr;
}
TEST * pTest;
pTest = (TEST *)pvData;
pTest[0] = a;
pTest[1] = b;
hr = SafeArrayUnaccessData(pSa);
if (FAILED(hr)) {
SafeArrayDestroy(pSa);
return hr;
}
VariantInit(&variant);
V_VT(&variant) = VT_ARRAY|VT_RECORD;
V_ARRAY(&variant) = pSa;
This code uses basic COM functions instead of MFC, but CComVariant is designed to work with any function that takes a VARIANT. If you are using ATL, there is a CComSafeArray class that can simplify it some more.
Nathan
|
|
|
|
|
Thanks..
I thought that i create array uncorrect, but now i understand that value can't to be an array.
ISQ 469907496
|
|
|
|
|
//Its tt.java simple Helloworld program .which i am willing to call from c++
// i created .class and .h file of it !
public class tt {
public static void main(String[] args) {
System.out.println("Hello World ");
}
}
//*****************************************************************************************
//i wrote it in vc++ 6.0
//for this i added path of tt.h(created using javah) in preprocessor path(underprojects=>setting=>c/c++ tab)
//then added path of jvm.lib (under projects=>setting=>link tab)
#include "jni.h"
#define PATH_SEPARATOR ';' /* define it to be ':' on Solaris */
#define USER_CLASSPATH "C:\j2sdk1.4.2_05\bin" /* where tt.class is */
int main()
{
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jclass stringClass;
jobjectArray args;;
JavaVMInitArgs vm_args;;
JavaVMOption options[1];
options[0].optionString ="-Djava.class.path="USER_CLASSPATH;
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
// exit(1);
}
cls = (env)->FindClass("tt");
if (cls == 0) {
// goto destroy;
}
mid = (env)->GetStaticMethodID(cls, "main","([Ljava/lang/String;)V");
if (mid == 0) {
// goto destroy;
}
jstr = (env)->NewStringUTF(" from C!");
if (jstr == 0) {
// goto destroy;
}
stringClass = (env)->FindClass("java/lang/String");
args = (env)->NewObjectArray(1, stringClass, jstr);
if (args == 0) {
// goto destroy;
}
(env)->CallStaticVoidMethod(cls, mid, args);
//destroy:
if ((env)->ExceptionOccurred()) {
(env)->ExceptionDescribe();
}
(jvm)->DestroyJavaVM();
return 0;
}
/// After doing that much ! i got this LINKING TIME ERRORs
--------------------Configuration: ltry - Win32 Debug--------------------
Compiling...
Skipping... (no relevant changes detected)
tr.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/ltry.exe : fatal error LNK1120: 1 unresolved externals
// please help me sir....what chages i should do so that it gets run n calls java method ?
|
|
|
|
|
I try to call a function inside a aggregated interface IMyInterface
and it pops up this error ->
Run-Time Check Failure #0 - The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.
This is the code that i used,
IMyInterface* pMy = NULL;
HRESULT hr = m_pInterface->QueryInterface(__uuidof(IMyInterface),
(void**)&pMy);
pMy->GetValue();
When i call the GetValue function the Run-Time error comes up.
Any Idea?
|
|
|
|
|
donguy76 wrote: I try to call a function inside a aggregated interface IMyInterface
and it pops up this error ->
Run-Time Check Failure #0 - The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.
I only have the obvious ideas. What calling convention is GetValue declared as?
Nathan
|
|
|
|
|
i am trying to use dll created in VC++ in ASP.Net but it gives an error of Security i have try caspol but still it gives an error.
Waiting for solution
Best Regards,
Chetan Patel
|
|
|
|
|
Does anyone know how the Groove 'Folder Sync' button is added to the standard Windows Explorer toolbar?
|
|
|
|
|
Hi,
Why we need COM. I know i have asked this question already, but i need direct answer in line or two
Thanks
|
|
|
|