|
hi:
i want to change the recipents of outlook2003 after the user clicked the send-button. For example, the old email-address is "aaa<aaa@aaa.com>" , and i want to change it to "aaa<bbb@bbb.com>". the display-name is kept, but the email-address is changed.
i use function IExchExtMessageEvents::OnCheckNames(IExchExtCallback *lpExchangeCallback), as following code:
STDMETHODIMP mymail::OnCheckNames(IExchExtCallback *lpExchangeCallback)
{
HRESULT hRet = S_OK;
LPMESSAGE lpMessage = NULL;
LPMDB lpMdb = NULL;
LPADRLIST pRecipentRows = NULL;
ULONG ulValues, ulTag;
lpExchangeCallback->GetRecipients(&pRecipentRows);
if( pRecipentRows->cEntries == 0 )
return S_FALSE;
for(unsigned long n = 0; n < pRecipentRows->cEntries; n++ ){
ulValues = pRecipentRows->aEntries[n].cValues;
for(unsigned long i = 0; i < ulValues; i++){
ulTag = pRecipentRows->aEntries[n].rgPropVals[i].ulPropTag;
if( PR_EMAIL_ADDRESS == ulTag || PR_DISPLAY_NAME == ulTag){
//new address
char* p = "bbb@bbb.com";
char* pNewContact = NULL;
MAPIAllocateBuffer(strlen(p)+1, (LPVOID FAR *)&pNewContact);
strcpy(pNewContact, p);
//change email address
pRecipentRows->aEntries[n].rgPropVals[i].Value.lpszA = pNewContact;
}
}
}
hRet = lpExchangeCallback->SetRecipients(pRecipentRows);//hRet is S_OK;
return hRet ;
}
when i debugging, the "bbb@bbb.com" is set to the pRecipentRows, but the outlook2003 still send email as old emil-address "aaa@aaa.com". why?
who could help me?
thanks alot
my email: how_fly@yahoo.com
|
|
|
|
|
hi,
I want to know how do we use BSTR and VARIANT .Can any one please tell where to find the information about these?
Thank You
|
|
|
|
|
MSDN (Microsoft's Developer web pages) will tell you everything you need to know. Also, you might want to try Google, using "BSTR" and/or "VARIANT" as your search parameters.
msdn.microsoft.com
www.google.com
Hope that helps!
|
|
|
|
|
I want to know, What Design Pattern does ATL/COM is based upon, I dont want what ATL/COM support, What I need is ON WHAT DESIGN ATL/COM is build upon???
regards
Balkrishna Talele
|
|
|
|
|
I am not too sure, but it is based on "bridge" pattern.
thanks,
Mac
-- modified at 6:03 Tuesday 11th July, 2006
|
|
|
|
|
hi to all and best of luck. )I'm stuck-up here with the problem .. I could manage to pass string to another process/application using WM_COPYDATA but it takes v. long to pass a structure.
i wish if you can give me any code that allows passing "structure" between 2 applications
------------this is class one - sending message
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
#Region "API Declaration"
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Private Declare Auto Function SendMessage Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As CopyData) As Boolean
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer, _
ByVal lParam As Integer) As IntPtr
#End Region
#Region "process for messanging to application GLOBAL_IDENTITY_TWO"
'get handle of globlal application named GLOBAL_IDENTITY_TWO
Public ReadOnly Property GET_HANDLE_TWO() As IntPtr
Get
Return FindWindow(vbNullString, GLOBAL_IDENTITY_TWO)
End Get
End Property
Structure PT
Dim x As Object
Dim y As Char
Dim xy As String
End Structure
Dim MyVariable As New PT
Public Function sendMessageToTwo()
Dim data As CopyData
Dim message As String = "this is to be sent"
Dim hwndTarget As IntPtr
Dim MessageId As IntPtr
hwndTarget = Me.GET_HANDLE_TWO
MessageId = ONE_TO_TWO_MESSAGEID()
MyVariable.x = message
MyVariable.y = "c"
MyVariable.xy = "String is here"
System.GC.KeepAlive(MyVariable)
data.lpData = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
data.cbData = Marshal.SizeOf(MyVariable)
Dim MyPointer As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
Marshal.StructureToPtr(MyVariable, data.lpData, True)
SendMessage(hwndTarget, WM_COPYDATA, Me.Handle, data)
MsgBox("WM_COPYDATA")
Exit Function
If Not System.IntPtr.Zero.Equals(hwndTarget) Then
Call PostMessage(hwndTarget, MessageId, 0, 0)
MsgBox("Message sent")
Else
MsgBox("Unable to send Message ! probably GLOBAL_IDENTITY_TWO Not found")
End If
End Function
Public ReadOnly Property ONE_TO_TWO_MESSAGEID() As IntPtr
Get
Static objONE_TO_TWO_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(ONE_TO_TWO_MESSAGEID) Then
objONE_TO_TWO_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objONE_TO_TWO_MESSAGEID
End Get
End Property
#End Region
Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_ONE
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
----this is class two-listening to message-----------
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer,ByVal lParam As Integer) As IntPtr
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Structure PT
Dim x As Object '<<<----- whenever i use object as member of a structure i get an exception An unhandled exception
'of type 'System.ExecutionEngineException' occurred in mscorlib.dll if i use string as a
'member there is no error
Dim y As Integer
Dim xy As Integer
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_COPYDATA
Dim data As CopyData
Dim message As String
Dim MyPoint As New PT
data = CType(m.GetLParam(GetType(CopyData)), CopyData)
MyPoint = Marshal.PtrToStructure(data.lpData, GetType(PT)) <<<---- @ this point i'm getting the error [debug]
'MyPoint = Marshal.PtrToStructure(CType(m.GetLParam(GetType(CopyData)), CopyData).lpData, GetType(PT))
MsgBox(CType(MyPoint.x, String))
Case TWO_TO_ONE_MESSAGEID().ToInt32
MessageBox.Show("GOT A MESSAGE FROM ONE--- CALLING METHOD A", "VBNETMessaging")
Call A()
End Select
MyBase.WndProc(m)
End Sub
Private Sub A()
MsgBox("Message from Method A")
End Sub
Public ReadOnly Property TWO_TO_ONE_MESSAGEID() As IntPtr
Get
Static objTWO_TO_ONE_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(objTWO_TO_ONE_MESSAGEID) Then
objTWO_TO_ONE_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objTWO_TO_ONE_MESSAGEID
End Get
End Property
#Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_TWO
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Use .Net Remoting 2.0.
You can choose IPC instead of the usual TCP.
Take a look: .NET Remoting 2.0 - IPC
Eran Aharonovich (eran.aharonovich@gmail.com )
Noviway
|
|
|
|
|
I have MFC application that works as EXE COM SERVER . I wish to convert it to EXE SERVICE in purpose to connect the client application via the net .
I am all ready have a connection point in to the EXE COM SERVER to connect the client . but my main problem is to activate DCOM SERVER in side of the net.
Thank you .
|
|
|
|
|
My normal technique for invoking MySql is producing LNK2001 errors from a com project, using paths that work for an exe based application. Anyone succeed in making this a MySQL connection from a COM dll?
Thanks
Ger
|
|
|
|
|
Hello !
Try by importing the msado32.dll and use the smart pointers generated !
-Malli...!
|
|
|
|
|
I have a standard DLL in visual c++ 6.0 that I can call from other exes for things like conveting CString to Integer or Float. I want to call it from a com object but I am geting declspec link errors. I didnt need to do any declspec(export) or declspec(import) when the exe was calling it. Is this my prob lem?
Ger
|
|
|
|
|
What's the exact error?
Basically, when you cbuild the conventional DLL, all exported symbols must be declared with __delcspec(export). When you use it (i.e. #include the respective headers), these ver symbols need __declspec(import). There are a few cases wehre it works without nonetheless (and there are other ways to export symbols), but that's pressing your luck.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
I have a c++ unmanaged code (ATL/WTL) from which I need to consume a c# assembly with a CCW (Com Callable Wrapper) Exporting the c# side for COM is straight forward, and when I import it at design time it imports fine and my .tlh file is generated correctly... However when I try to CoCreateInstance at runtime I get 1 of 2 errors.. Either "Class not registered" or "File Not Found" I have run RegAsm on the assembly, with /codebase switch. I have also tried nocodebase switch. The C# assembly is in the same path as my c++ DLL. I have tried it in the path of the parent exe and system32. I have also tried strong naming the file and using GACUTIL to put it in the GAC. Each time, RegAsm goes fine, I check the registry and it all looks ok, but I continually get the "File Not Found" Hresult from CoCreateInstance...
In addition to this info... This was working great with VS 2003, but I have recently upgraded to VS2005 and this has started to happen when I did that upgrade.
Any ideas?
Jake-
-- modified at 7:32 Saturday 8th July, 2006
|
|
|
|
|
We created an ATL server in VC++. Diffrent vc++ clients from diffrent process use this Server. It was working fine. Now all clients introduce one more thread in their process. In order to share the Com pointer to the new thread, they use the global interface table.
We start all application at startup. Here all application will initialize Com Server pointer and place them into the global interface table. Some COM interface calls occur during start up from main thread. These calls are working fine.
In our system we allow only one application to process its messages. This message processing occurs in a different thread other than the main thread. The message handler function retrieves the COM pointer from global interface table and call required interface. This works fine for first application. But when we transfer execution right to next application, even though we can acquire the interface pointer from interface table successfully, the COM interface call fails and the reason I got is “Not enough storage is available to complete this operation”.
Any hint.
-- modified at 23:40 Sunday 9th July, 2006
|
|
|
|
|
Can two threads in the same process create separate instances of the same COM Component? I mean Thread1 will have its own COM instance and Thread2 will have its own. Do I have to create the COM Component in a special way to have the above feature?
I have an application which has several threads. Now each thread must have its own instance of the COM Component. Can anyone help?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Hello Hakuna,
>> Can two threads in the same process create separate instances of the same COM Component?
Answer : Yes, certainly.
>> Do I have to create the COM Component in a special way to have the above feature?
Answer : Just make sure that the COM Component is not a SINGLETON.
Contact me again if you need any further clarification.
Best Regards,
Bio.
|
|
|
|
|
Is there any way to implement the same functionality in case of SINGLETON class?
|
|
|
|
|
Hello George,
>> Is there any way to implement the same functionality in case of SINGLETON class?
I'm not sure what you mean specifically by "the same functionality". Perhaps you can elaborate on this point. However, two or more threads -can- create and use a SINGLETON COM object, even without knowing that the COM object is a singleton. Each thread will think its object is its very own when in actual fact it is shared across threads.
However, there will be a subtle internal difference which involves the apartment of the COM object and the apartment(s) of the client threads. If the COM object is an STA object, and the first thread that created it is an STA thread, then only this thread will have direct access to the object. The other threads will receive a PROXY to this COM object.
Contact me again if you need any further clarifications
Best Regards,
Bio.
|
|
|
|
|
Hi all,
I have a COM program written in VC++ (unmanaged). I got the managed code written in C#. My issue is I need to call the COM dll functions from my C# program.
Does any one have an idea how to do it? If so, please reply me with me some sample code.
Thanks
Sony
|
|
|
|
|
Hi. I am a newbie.
In C, I managed to read a file which consists of a single string.
How do I pass this string to VB via an OCX?
I was thinking of creating a safearray to do it but I am not to sure how to safearray a string. I have only managed to do it for numbers.
Thanks in advance!
|
|
|
|
|
No need to use a SafeArray.
If the string is using ANSI, convert it to UNICODE using MultibyteToWideChar API.
For the Unicode string, call SysAllocString to make it a "good" BSTR, which is the "VB-native" string type.
Depending on the parameter declaration, you need to SysFreeString the BSTR when you are done.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
Hi all,
Im new to ATL COM programming(2 weeks!). im using an api in my component.
unfortunately i havnt been able to load it appropriately(atleast this is what
the client says!). this is how i've done it... pls tell where im wrong.
i created an ATL class in the dll and added the following to the class' cpp
file in the global area
<br />
HINSTANCE hDll=LoadLibrary("API.dll");<br />
typedef short (*Init_type)();<br />
typedef short (*Close_type)();<br />
typedef short (*SetAnalog_type)(int,double);<br />
typedef short (*SetOutput_type)(int);<br />
typedef short (*ResetOutput_type)(int);<br />
typedef short (*IsInput_type)(int);<br />
<br />
Init_type Init;<br />
Close_type Close;<br />
SetAnalog_type SetAnalog;<br />
SetOutput_type SetOutput;<br />
ResetOutput_type ResetOutput;<br />
IsInput_type IsInput;<br />
<br />
Class::Class()
{<br />
Init = (Init_type)GetProcAddress(hDll,"Init");<br />
Close =(Close_type)GetProcAddress(hDll,"Close");<br />
SetAnalog = (SetAnalog_type)GetProcAddress(hDll,"SetAnalog");<br />
SetOutput = (SetOutput_type)GetProcAddress(hDll,"SetOutput");<br />
ResetOutput = (ResetOutput_type)GetProcAddress(hDll,"ResetOutput");<br />
IsInput = (IsInput_type)GetProcAddress(hDll,"IsInput");<br />
}<br />
after this i've created other methods in the class where i use these api
functions.
the dll compiles without problems, but when i use these methods in a vb
client i get this error...
The instruction at "0x00000000" referenced memeory at "0x00000000". The
memmory could not be "read".
Click on OK to terminate the program...
pls help... maybe i dont know how to load an api...im new to this. can
somebody give a link to a sample code where the coder has loaded the api and
used the functions.
Thanks in advance
Nikhil
|
|
|
|
|
I am writing windowless activex control with ATL. i want this control to blink with certain rate.
I am using all the techniks ( bitmap drawing, flickerfree activation ... ) but I still see some flicking. When I use windowed activation everighing is fine. For blinkking I am using timer funcion
Can somebody dive me some idea how to fix the problem
|
|
|
|
|
Hi,
I am a newbie and was not sure about the category under which my question comes. Therefore please move it to appropriate category if you guys feel so.
I have an address book application which I want to integrate with outlook/outlook express.
Can someone please tell me how can I do it ? Some tutorial or link.
My application is in some way similar to plaxo.
Thanks a lot
|
|
|
|
|
Hi all,
I have trouble with a vc dll com which im using in a vb client...
i've imported a third party ocx and a dll which consists of API functions
(basically its architecture is similar to kernel32.dll) in my vc com dll and
ive used them in other classes.
i wrote a class called myerrorhandling in which has a public method
error_logger
this is the method
<br />
STDMETHODIMP errorhandling::error_logger()<br />
{<br />
FILE *fptr;<br />
char error[10]={"ERROR***"};<br />
fptr=fopen("C:\\Debug.txt","a+");<br />
fprintf(fptr,error);<br />
fclose(fptr);<br />
return S_OK;<br />
}<br />
i get this error when i create an object of the errorhandling class in vb
<br />
Run-time error '-2147024770 (8007007e)':<br />
<br />
Automation error<br />
The specified module could not be found.<br />
infact i get this error while creating an object of any class in the dll
i havnt used any api functions or thirdparty dll objects anywhere in this
class(error handling)...
i created another com dll in vc and added this errorhandling class and it
worked fine.
what could the problem be?
thanks in advance
Nikhil
|
|
|
|