ActiveX or COM or ...?

R

Randy Dietz

Hi, how can I create a simple non-UI dll or component which will be used by
MS Access and .ASP apps which I can build with Visual C++ .net? An example
or template which would allow me to paste in C code without learning all the
C++ details would be perfect.

Thanks,
Randy
 
M

Mark Schupp

MSVC++ has wizards to create server-side com objects. I would expect that
C++ .net would as well. There should also be some sample code available as
well.
 
G

Guest

Why dont you try to use VB5/6/VB.NET for example if C++ like syntax is not
the one that you like?

: Hi, how can I create a simple non-UI dll or component which will be used
by
: MS Access and .ASP apps which I can build with Visual C++ .net? An
example
: or template which would allow me to paste in C code without learning all
the
: C++ details would be perfect.
:
: Thanks,
: Randy
:
:
 
S

Steven Cheng[MSFT]

Hi Randy,

Thank you for posting here. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)
 
R

Randy Dietz

People in other newsgroups suggested posting here. A few people recommend
using a COM Server or ATL Server but I tried that using
file|new|project|visual c++ projects|ATL|ATL project and couldn't get VBA
code to recognize MyFunc99 maybe because my VBA Declare statement is
incorrect.

In VBA I used

Private Declare Sub MyFunc99 Lib "C:\Documents and Settings\default\My
Documents\Msaccess\Test4" (s1 As String)
....
Dim s1 As String
MyFunc99 (s1)

A summary of info and notes from myself and other posters...
1. create a simple non-UI dll or component which will be used by MS Access
and .ASP apps.
2. use COM because .ASP can't use a DLL.
3. the component needs to work on both non-.net and .net systems if
possible.
 
R

Randy Dietz

Class view shows that rsdm2() is exported I think...

Test4
...
Irsd2
...
rsdm2(BSTR *s1)

and the build log shows that regsvr32 test4.dll registers the dll so how do
I get MS Access to use the dll? Tools|ActiveX Controls lists many controls
but no rsd* nor test4* symbols.

Build Log ------- Build started: Project: test4, Configuration:
Debug|Win32 -------

Command Lines Creating temporary file "c:\Documents and
Settings\default\My Documents\Visual Studio
Projects\test4\Debug\RSP000013.rsp" with contents
[
/Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_ATL_ATTRIBUTES"
/D "_WINDLL" /D "_ATL_STATIC_REGISTRY" /D "_MBCS" /Gm /EHsc /RTC1 /MDd
/Yu"stdafx.h" /Fp"Debug/test4.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c
/Wp64 /ZI /TP
".\toupper.cpp"
".\test4.cpp"
".\rsd2.cpp"
".\rsd1.cpp"
]
Creating command line "cl.exe @"c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\RSP000013.rsp" /nologo"
Creating temporary file "c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\RSP000014.rsp" with contents
[
/Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_ATL_ATTRIBUTES"
/D "_WINDLL" /D "_ATL_STATIC_REGISTRY" /D "_MBCS" /Gm /EHsc /RTC1 /MDd
/Yc"stdafx.h" /Fp"Debug/test4.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c
/Wp64 /ZI /TP
".\stdafx.cpp"
]
Creating command line "cl.exe @"c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\RSP000014.rsp" /nologo"
Creating command line "rc.exe /d "_DEBUG" /l 0x409 /I "Debug"
/fo"Debug/test4.res" ".\test4.rc""
Creating temporary file "c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\RSP000015.rsp" with contents
[
/OUT:"Debug/test4.dll" /INCREMENTAL /NOLOGO /DLL /IDLOUT:"_test4.idl" /DEBUG
/PDB:"Debug/test4.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"Debug/test4.lib"
/MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib
".\Debug\rsd1.obj"
".\Debug\rsd2.obj"
".\Debug\stdafx.obj"
".\Debug\test4.obj"
".\Debug\toupper.obj"
".\Debug\test4.res"
]
Creating command line "link.exe @"c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\RSP000015.rsp""
Creating temporary file "c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\BAT000016.bat" with contents
[
@echo off
cd .\Debug
regsvr32 /s "test4.dll"
]
Creating command line ""c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\BAT000016.bat""
Creating temporary file "c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\BAT000017.bat" with contents
[
@echo off
regsvr32 /s /c "c:\Documents and Settings\default\My Documents\Visual Studio
Projects\test4\Debug\test4.dll"
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Performing
registration"
exit 1
:VCEnd
]
Creating command line ""c:\Documents and Settings\default\My
Documents\Visual Studio Projects\test4\Debug\BAT000017.bat""
Output Window Compiling...
stdafx.cpp
Compiling...
toupper.cpp
test4.cpp
rsd2.cpp
rsd1.cpp
Generating Code...
Compiling resources...
Linking...
Creating library Debug/test4.lib and object Debug/test4.exp
Microsoft (R) 32b/64b MIDL Compiler Version 6.00.0361
Copyright (c) Microsoft Corporation 1991-2002. All rights reserved.
Processing .\_test4.idl
_test4.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\prsht.idl
prsht.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\wtypes.idl
wtypes.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\basetsd.h
basetsd.h
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\guiddef.h
guiddef.h
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\mshtml.idl
mshtml.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\ocidl.idl
ocidl.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\oleidl.idl
oleidl.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\objidl.idl
objidl.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\unknwn.idl
unknwn.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\oaidl.idl
oaidl.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\servprov.idl
servprov.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\urlmon.idl
urlmon.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\msxml.idl
msxml.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\dimm.idl
dimm.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\mshtmhst.idl
mshtmhst.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\docobj.idl
docobj.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\exdisp.idl
exdisp.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\objsafe.idl
objsafe.idl
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\oaidl.acf
oaidl.acf
Processing C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\include\ocidl.acf
ocidl.acf
Registering output...
Performing registration
Results Build log was saved at "file://c:\Documents and
Settings\default\My Documents\Visual Studio
Projects\test4\Debug\BuildLog.htm"
test4 - 0 error(s), 0 warning(s)
 
M

MSFT

Hi Randy,

hank you for using MSDN Newsgroup. I am Luke and I am review this issue
currently. As I understand, you want to create a component with VC++.NET
which can be used both in .NET application and Access application. Based on
the requirement, I think Class Library (.NET) should be a proper solution.
(File/New?Project/VC++ Project/Class Library (.NET) ). You can add your
functions in the source file and compile it to a DLL files.

To use the DLL file in another dot application, you can select "Project/Add
a reference", select the DLL file and add the reference file.

To use it in Access application, you first need register it as a COM
librrary with a utility "Regasm.exe":

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpgrfassemblyregistrationtoolregasmexe.asp

In Access, you can click menu "Tool/Reference" and find the type library in
the list.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Mark Schupp

You do not use declare statements with com object.

After the com object is compiled and registered you use CreateObject just as
you would for a built-in asp object.

set myobj= createobject("mydll.myobject")

Dim s1

s1 = ""

myobj.myfunc( s1 )

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
 
R

Randy Dietz

Luke, several others suggested that a COM object will work with both
MSAccess and .ASP. I used oleview.exe 'object classes->all objects' and
there are no rsd* objects so it appears that regsvr32 fails when the vc++
build calls it even though there are no err messages. I copied and built

LABRADOR Sample: Implements a Server with an Out-of-Proc Custom Interface
and Compiler COM Support

then tried oleview and LABRADOR is listed under 'object classes->all objects
' so I must be missing something in my project.


I started over and did...

create test9 with file|new|project|visual c++ projects|ATL|ATL project
right-click test9 in solution explorer
add the rsdm1 class using add|add class|visual c++|ATL|ATL Simple Object
rebuild all and the build log has

regsvr32 /s /c "c:\documents and settings\default\my documents\visual studio
projects\test9\debug\test9.dll"

run oleview.exe 'object classes->all objects' and there are no rsd* objects
listed.

Do I need to do something more to make rsdm1 a COM object or am I missing
something else?
 
R

Randy Dietz

When I run

regsvr32 /c "c:\documents and settings\default\my documents\visual studio
projects\test9\debug\test9.dll"

I get a messagebox that says

DllRegister in c:\documents and settings\default\my documents\visual studio
projects\test9\debug\test9.dll succeeded.

but oleview doesn't list any rsd* objects.
 
R

Randy Dietz

Mark, I just found my COM objects in oleview. They're named Crsd* not rsd*
but I still can't access them using COMAddIns in vc++. How can I use the
MSAccess CreateObject function with "c:\documents and settings\default\my
documents\visual studio projects\test9\debug\test9.dll" and it's class
Crsdm1? What is the syntax?
 
M

MSFT

Hi Randy,

From another message, I found youn saw Crsd* not rsd*. In fact, this name
is determined by the class name you defined in the .h file. You may open
the ATL project and check the .h file. By the way, for a ATL project, we
only need to compile it. regsvr32 is not necessary for local computer.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

MSFT

Hi Randy,

To use this ATL Class with createobject, you need:

CreateObject("ProjectName.ClassName")

Project name is the name for your ATL project and Class name is the name in
.h file

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top