|
Your information was useful. Thanks.
I read Don Box as well. Can you tell me from where can I get more details about class emulation, and how to implement it?
|
|
|
|
|
Hi,
I am developing activeX control in VC++.
My control is built with usage of two other OCX files so I pack three OCX files and INF file in one single CAB file.
It is being placed on the web page with CODEBASE tag and class id of my control.
It works fine but I need to get USER_LOGON to verify user's permissions to access database (this is INTRANET application)
to get user login I am using VBScript:
<%
full_user_id = Request.ServerVariables ("LOGON_USER")
Response.Write full_user_id
i=InStrRev(full_user_id,"\",-1,vbTextCompare)
if i>0 then
user_login = Right(full_user_id,len(full_user_id)-i)
else
user_login = full_user_id
end if
%>
and i get the proper string in 'user_login'
the question is - how can I pass this user_login variable to my C++ code ?
i would guess by setting :
<param name="web_user_name" value="<%" response.write="" user_login="" %="" />>
Am I on the right track ? Does anyone know how to pass USER_LOGON variable from the html page to activex control's code (VC++) ?
thank you
|
|
|
|
|
How do I change the initial size of the AX(COleControl) in the VC++ (or VB) resource editor when it's first time dropped onto the form/dialog?
GetViewExtent or GetNaturalExtent doesn't seem to be called...
|
|
|
|
|
First client creates an instance of a remote COM object via CoCreateInstanceEx, then calls one of its method remotely. In that method, assume Checker(), some information of the client is checked to see if he has the right to access things on Server further. If OK, the Checker() will create an instance of another COM object named CoreServer, and transfer the pointer to one of its Interface back to Client. How can I finish the procedure with DCOM library? I think there maybe 3 ways for the Checker() to create and transfer:
1.CoCreateInstance
2.CoCreateInstanceEX
3.Moniker
but no way seems work
please help me, thanks.
|
|
|
|
|
Hi,
I'm a VB programmer who is trying to convert an old C console application to a C++ ATL COM DLL for use with a VB GUI.
My code basically allows the client to set a filename and then call a function which launches a private function in a seperate thread and returns immediately.
My private function then trundles along, raising events to inform the client of it's progress along the way.
All sounds good so far, unfortunately my code doesn't work, all my properties, methods, variables and so on were created by wizards.
Here is my implementation file (Asynch.cpp):
#include "stdafx.h"
#include "AsynchEg.h"
#include "Asynch.h"
// Required for _beginthread and _endthread - do not remove
#include "process.h"
#include "comdef.h"
STDMETHODIMP CAsynch::RequestNewThread()
{
// Begin a new thread and start the _NewThread function
_beginthread(_NewThread, 0, (void*)(this));
return S_OK;
}
void CAsynch::_NewThread(void* pCaller)
{
FILE *file;
BSTR wfilename;
char nfilename[256];
LPSTR filename;
// Cast the passed void pointer to a CAsynch object
CAsynch* pAsynch = (CAsynch*) pCaller;
// Convert the FileName property to a character array for use in fopen
pAsynch->get_FileName(&wfilename);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, wfilename, -1, nfilename, sizeof nfilename
, NULL, NULL);
filename = nfilename;
// Open the file
if((file = fopen(filename, "rb")) == 0)
{
// TODO: Raise error
}
else
{
// Close the file
fclose(file);
// Tell the calling object to raise it's ThreadDone event
pAsynch->Fire_ThreadDone();
}
// End this thread
_endthread();
}
// Returns the FileName property
STDMETHODIMP CAsynch::get_FileName(BSTR *pVal)
{
// Populate the pointer with the private variable
*pVal = m_FileName;
return S_OK;
}
// Sets the FileName property
STDMETHODIMP CAsynch::put_FileName(BSTR newVal)
{
// Copy the new value to the private variable
_bstr_t NewBSTR;
NewBSTR.Assign(newVal);
m_FileName = NewBSTR.copy();
return S_OK;
}
If I run my VB exe then I get a memory exception.
If I run the C++ end in debug then I get an access violation on the Invoke line of the Fire_ThreadDone function.
If I run VB in debug mode my code works and my event is raised.
What is going on?
If you need a copy of my projects (VC++6 and VB6) then mail me and I'll send you a copy.
Also, can anyone tell me how to raise run time errors to my VB client?
Any consttuctive criticism / advice is greatly appreciated.
Best Regards,
Rob Brown
|
|
|
|
|
I'm a VB programmer who is trying to convert an old C console application to a C++ ATL COM DLL for use with a VB GUI.
Good luck, you'll need
I've done async multithreaded programming in VB, and believe me: it's ugly, and for seasoned C++ COM programmers. MS says: "VB clients are monothreaded."
Well, you'll face 2 main problems, and I would start learning this topics to acomplish this:
- Building a message loop.
- Synchronizing Win32 objects: Events
- marshalling interface pointers between threads
If you fail to use them, your code will hang, or your code will cause a GPF.
Tip: You'll need another thread that creates the object and stay forever in a message pump.
Furor fit laesa saepius patientia
|
|
|
|
|
I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString.
Now I want access to this function from another application to do it I type the next code.
In the ATL COM
...
__declspec(dllexport) CString GetEncodedText(CString p_sPlainText);
...
In the other application
...
hDLL = AfxLoadLibrary("BabMD5.dll");
if (hDLL != NULL) {
typedef CString (CALLBACK *ENCODETEXT)(CString);
ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText"));
if ( p_encodeText != NULL) { // -> NEVER GET HERE
strEncoded = (*p_encodeText)( strPlain );
}
AfxFreeLibrary( hDLL);
}
...
Anybody knows what's happen? Why I can't get the function?
Thanks in advance
|
|
|
|
|
If your DLL is COM this is not the way to do it. Think COM not WIN32.
You need to create an instance then call the method.
CMyObject MyObj;
CoCreateInstance(__uuidof(myobj), .... )
BSTR bstrText
HRESULT hr = MyObj->GetEncodedText(&bsrText);
Notice also that you need a BSTR not CString. Since you are using ATL I'd also loose the MFC support, it doesn't get you anything but more overhead.
|
|
|
|
|
Hi,
While trying to create an object from the client ( remotely) i get the "Access denied" error. I have made sure that the security setting are correct by giving myself full control, that didn't help.
This used to work until i modified the dcomcnfg setting to run application on local computer as well as the remote one ( basically i checked both boxes, after restoring original setting hell the Access denied error started appearing.
any ideas??
* i know i have access to the remote machine as i have access to files on it through explorer.
Alii
|
|
|
|
|
Register the Server.exe and its proxy.dll (if available) on the client machine too. Then you can delete those two files from the client machine. It maybe work.
|
|
|
|
|
Salam,
Actually we've faced such problem before, and everytime we do somthing to solve this problem, and at the end, we don't document what we have found. But the last time we solved this problem, we made a decesion that we have to document this DCOM Access Denied problem thorouly. I have a Word Document (.DOC) which has the complete steps to configure the source and the destination machines which containes the DCOM component.
I'll try to attach this document to this site soon after I refine it . Please, keep track within the coming two days to find this document.
Regards,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
The article has been posted:
http://www.codeproject.com/useritems/dcomcnfg.asp
Enjoy it,
ShadiK.
Shadi Al-Kahwaji.
|
|
|
|
|
Hello,
Can somebody give me the advantages/disadvantages of using VB to develop COM component instead of using ATL to do the same. Any links to such comparisons are also appreciated.
Ganesh.M.Ramaswamy
|
|
|
|
|
Advantages:
Any idiot can code VB COM components.
Disadvantages:
Only idiots code VB COM components.
Furor fit laesa saepius patientia
|
|
|
|
|
nice one, daniel.
Sorry ganesh I do not have any links to pass on. As it must be obvious to you, in VB you don't really get a taste of what is COM. In VC++/ATL you get to meddle around with the inner working's of COM and get a real feel of how complicated COM actually is.
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
Ease of development v's tighter (better;) ) code.
|
|
|
|
|
Hi All,
I am developing an application which uses SQL Server CE as the database, from which I need to synchronize the data to the SQL Server on the server machine. When I tried to synchronize the data using the emulator, it worked perfectly. But, when I tried the same application on my iPAQ pocket PC, I got an error, "DLL for the class not found". When I debugged, the CoCreateInstance() method fails and returns the HRESULT with the error code corresponding to this error message. When I checked the CLSID on the registry, an entry was there in the registry and the corresponding DLL was there in the /Windows directory . Could any one help me to come out of this problem. Any help on this highly appreciated.
This is the line of code I wrote:
hr = CoCreateInstance(CLSID_RemoteDataAccess, NULL, CLSCTX_INPROC_SERVER, IID_ISSCERDA, (LPVOID *)&m_pRda);
Jabir
|
|
|
|
|
hello
i have this com function (using ATL):
STDMETHODIMP Cmanager::iniGetString(BSTR sSectionName, BSTR sKeyName, BSTR sFileName, BSTR *sRetVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
char sTemp[MAX_PATH];
memset(sTemp, '\0', MAX_PATH);
GetPrivateProfileString (_bstr_t(sSectionName), _bstr_t(sKeyName), "none", sTemp, MAX_PATH, _bstr_t(sFileName));
sRetVal = SysAllocString ((OLECHAR *)sTemp);
return S_OK;
}
the sRetVal return nothing.
how can i return sTemp?
|
|
|
|
|
Hi,
Try using the .copy member of the _bstr_t class. Something like this has worked well for me:
STDMETHODIMP XXX::get_String(/*[out, retval]*/ BSTR* pVal)
{
HRESULT hr;
_bstr_t aBstr = "Hello!!";
*pVal = aBstr.copy();
return S_OK;
}
|
|
|
|
|
There are two problems with the code. First, sRetVal is a pointer to a BSTR, so assigning to sRetVal won't do anything. Second, sTemp isn't a Unicode string, so casting it to (OLECHAR*) will give you unpredictable results. You can use CComBSTR to handle the memory allocation and character set conversion:
CComBSTR bstr ( sTemp );
*sRetVal = bstr.Detach();
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
Hello everyone!I am Sree Ram working on COMAddins for Word2000 and Excel2000.I have programmatically added a Command Bar and Menu Bar (and menu items) for both Word2000 and Excel2000.The button Handlers for these r working properly according to the code.My problem is both the Word and Excel are giving a macro security warning.The Word2000 is saying "the macro cannot be found or has been disabled because of your Macro Security settings" and the Excel2000 is saying "The macro cannot be found".I added the command bar and menu bar programmatically using ATLCom.I changed the security level by using tools/macros and templates and security.But this didnot solve my problem.Can anyone who has previously solved this problem or is able to solve this problem kindly help me to solve this problem.Please reply back to me.
Bye
Thanking You,
Sincerely,
Sree Ram
|
|
|
|
|
Does the MFC classes CFtpFileFind and CFtpConnection support timeouts?
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
CFtpFileFind don't need Timeout because is a boolean, the file is there or not...
CFtpConnection, have a own timeout, You can't set the timeout time. I think that the timeout can be seted in the registry.
Cheers!!!
Carlos Antollini.
Happy Friday
|
|
|
|
|
I am trying to instantiate a COM Server on a remote machine without
configuring either the client or the server machine via DCOMDNCFG.EXE.
Basically, the COM Server will NOT be registered on the client machine, but
only registered on the server machine. The calling client is a VB COM
object trying to remote another COM object. I have it working with some
objects that I wrote... but I cannot get it to work with the SQLDMO objects
(Server/Restore).
I found some information on the web for doing something similar, but it only
worked if you had a dummy COM server with the same interface registered on
the client machine so that when calling CLSIDFromProgID(), the call would
succeed in retrieving the CLSID for the later call to CoCreateInstanceEx().
I changed it to pass in the CLSID so I didn't need the call to
CLSIDFromProgID(), and I convert it to a UUID structure for passing to
CoCreateInstanceEx(). It works with some other VB objects I wrote... and
at first, I thought it was because they are registered on the client
machine. However, so are the SQLDMO objects, and they fail to work using
this method.
See the code below. Anyone have any ideas for me?
Thanks,
Rob
--
Public Function CreateObjectRemoteByCLSID(ByVal strCLSID As String, ByVal
strServerName As String) As Object
' NOTE: Can be used even if the CLSID specified is NOT installed on
client machine.
Const PROC_NAME = MODULE_NAME & ".CreateObjectRemoteByCLSID"
Const RPC_S_OK As Long = 0
Dim server() As Byte
Dim QI As MULTI_QI
Dim SS As SERVER_STRUCTURE
Dim refiid(16) As Byte
Dim lngReturn As Long
Dim CLSID As UUID
' ensure that leading and trailing {} are dropped
If Right$(strCLSID, 1) = "}" Then strCLSID = Left$(strCLSID,
Len(strCLSID) - 1)
If Left$(strCLSID, 1) = "{" Then strCLSID = Mid$(strCLSID, 2)
' build UUID structure from CLSID
lngReturn = UuidFromString(strCLSID, CLSID)
If lngReturn <> RPC_S_OK Then
Err.Raise -1, PROC_NAME, "Invalid CLSID: " & strCLSID
End If
' setup variables for CoCreateInstanceEx; initialize OLE
GetIIDforIDispatch refiid() 'set an IID for IDispatch
QI.pIID = VarPtr(refiid(0)) 'point to the IID
server = strServerName & Chr$(0) 'specify the server
OleInitialize 0 'initialise OLE
' point to server name and
' invoke a remote instance of the desired object
SS.pServer = VarPtr(server(0))
lngReturn = CoCreateInstanceEx(CLSID, 0, 16, SS, 1, QI)
If lngReturn <> 0 Then
Err.Raise lngReturn, PROC_NAME, "CoCreateInstanceEx returned error
code " & Hex$(lngReturn)
End If
' pass back object reference
Set CreateObjectRemoteByCLSID = QI.pInterface
End Function
|
|
|
|
|
I am developing an application which confirms to COM specifications in VC++ 6.0 using ATL COM. Some times I need to pass nearly more than 100 variable values across components, for which I need to provide Set / Get functions to set the get the same, which is tedious.
In order to avoid writing 200 functions, I have a thought of creating a structure or class with those variable and sending the object of this structure/class across components.
Could you please help me to accomplish the same?
(with some sample code )
Thanking you ...
Shesh
|
|
|
|
|