Simple COM component - visual-c++

Sorry for this stupid questions, but I've never developed COM components. I try to learne interaction between .net and COM though I need to create COM. Questions:
1)Why "STOP" sign appear in solution explorer when I am create COM project in VS2010 using ATL wizard(look at image)?
2)How can I add my own class for this project?
3)Where can I search simple tutorial for beginners?

Because those are supplementary "Generated Files", they are excluded as not necessary for the build (unless another source file references them explicitly, of course). Stop sign means "excluded".
Adding an ATL Simple Object on MSDN
ATL Concepts and Tutorial, CodeProject

Related

.NET Core / .NET 6: Creating a TLB or DLL that can be added as reference in VBA

I am trying to do basically what it says in the title: I have created a class library (dll) using .NET 6.0 and I would like to add that as a reference in an Excel/Access VBA document. I diligently followed the steps here:
https://learn.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com
No matter what I try, I cannot add the resulting dll as a reference in Excel. I just keep getting the message: 'Can't add reference to the specified file'.
A bit more info: I am able to create the Assembly.comhost.dll file, and I think I have done everything correctly, but no joy.
This is rather frustrating, as doing this in .NET Framework is but a click of a couple of checkboxes. In .NET Core (.NET 6) It seems to be a bit of a nightmare. Also, being able to create a tlb from the dll was always a perfect confirmation that you would be able to add your reference in Excel.
ANY help is most welcome!
Thanks!
in the tutorial you hav ementioned, ther is a topic "Register the COM host for COM". here a file named "ProjectName.comhost.dll" is used to register the assembly to the registry as a COM type library.
After doing this, i could the assembly in VBS with the fowing conde:
set projectObject = CreateObject("ProjectNamespace.ProjectClass")
newValue = projectObject.ComputeNewValue("abc")
Right now, I was not able to establish a reference to that type library in my Excel 2016, but the code sample works in VBA as well.
I could also in VBA
Set projectObject = CreateObject("COMServer.Server")
MsgBox projectObject.ComputePi()
with this repository : https://github.com/dotnet/samples/tree/main/core/extensions/COMServerDemo
But that works only with Registered COM not with RegFree COM (Go check README).
Not every component is a suitable candidate for use under Reg-Free COM. A component is not considered suitable if any of the following are true:
The component is an out-of-process (ActiveX EXE) server. Only DLLs
are supported.
The component is a system component or part of the operating system,
such as XML, Data Access, Internet Explorer, or DirectX® components.
For example, you should not attempt to isolate components such as
Microsoft XML (MSXml.dll) or Microsoft Internet Controls
(SHDocVw.dll). These components are either part of the operating
system, or can be installed with a separate redistributable package.
The component is part of an application, such as Microsoft Office.
For example, you should not attempt to isolate components such as the
Microsoft Word Object Model or Microsoft Excel Object Model. These
two components are part of Office and can only be used on a machine
that has the full Office product installed on it.
The component is intended for use as an add-in or a snap-in, such as
an Office add-in or a control in a Web browser. Such components
typically require some kind of registration scheme defined by the
hosting environment that is beyond the scope of the manifest itself.
The other problem is an arbitrary application may not be designed to
recognize isolated components, as it probably doesn't have a way to
reference your component through a manifest.
The component manages a shared physical or virtual system resource.
For example, it could manage some kind of data connection shared
between multiple applications or a device driver for a print spooler.
Source : https://social.msdn.microsoft.com/Forums/en-US/cc08575d-3506-4a0f-a9e2-f23c2162ad38/using-net-excel-addin-with-registrationfree-com?forum=innovateonoffice
But I couldn't find a way to add it in Excel as a reference.

how to deploy a C# code to sharepoint 2007

in SharePoint 2007 (moss)
i need to implement a button . a button to create a custom action. this custom action registers a JavaScript file and a startup script. I have a C# code for this purpose.
i am not sure how to use the C# code. i was told the C# code just needs to be compiled into an assembly and deployed to the SharePoint server. however i dont quite know how can i do that.
( In case required, Reference to what i am trying to do is at this url )
any help appreciated .
In article you see that "feature" file contains
ControlAssembly="SharePointSolutionPack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4a7cd02bdf107f7a"
ControlClass="Motion10.SharePoint2007.SelectItemsAction"
That means the code goes inside class SelectItemsAction within Motion10.SharePoint2007 namespace.
SharePointSolutionPack is name of Dll file, which, when compiled, you copy to C:\Windows\assembly
However you must also copy feature defintion to (default location): C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\FEATURES
A helpful resource for You
Anyway, what i wrote is not very helpful because i'm not going into details. See this step-by-step example on creating sharepoint button (exactly what you need) that uses Visual Studio extension that helps you develop features and deploy them (without copy-pasting i meantioned above). (You'll learn how to create features with that article)
It is important to learn about sharepoint features, because before i understood how to create features, it was hard to do anything in sharepoint (couldn't understand sharepoint articles, when i saw code, all the time question pops up - where do i put that code?).
Good luck!
Here is a nice walkthrough. Hope it will help you out mate.
Deploy MSDN
Walkthrough: Creating a Webpart

Microsoft Communication control 6.0

Hello previously i was using VC++ 6.0 and MFC where i used Microsoft Communication Control 6.0 for serial communication its fine.But now i am using vc++.net 2003 and MFC, i added Microsoft Communication Control (MSComm1) but in class view there is no CMSComm class will creating . But in VC++ 6.0 if i add the this ActiveX Control.The CMSComm class will created by default where i can call member functions like SetPortOpen() , GetPortOpen() .
so any body tell me how to insert the MScomm control along with class.
Thanks in Advance
You may be having problems because this Microsoft update set the ActiveX killbit on the control. It will no longer function. MS suggests that we use a newer version of the control or the API.
EDIT: I did this with VC# and am not sure if the steps are the same with VC++. I need to install it and try it before providing a better response.
Since serial port support wasn't added to .Net until version 2.0 I had to do the same thing for .Net 1.1 apps. In my project I added a reference to MSCommLib and added the MS Communications Control, version 6.0, to my toolbox. After dragging one onto the form I was able to program against it. You should also have a reference to AxMSCommLib, AxInterop.MSCommLib.dll (COM interop not port).
Sorry, I opened the project and can't find a way to add it to the Class View, but once you have a reference and create a variable like "private AxMSCommLib.AxMSComm com;" you can use the intellisense to see the methods and members of the object.
You can also see these with the Object Browser. If you have the reference set, open the object browser and then click on AxMSComm. All of the members should be listed in the pane to the right side. There isn't much help for how to use each of the members here.

Access SharePoint objects from Delphi

We need to read and write the objects in SharePoint, such as the appointments (events) in SharePoint, from Delphi, what's the best/easiest way to do it? Any advises are appreciated! Thank you.
If you are able to use .NET references in Delphi and can develop on a SharePoint server then use the SharePoint Object Model. This is the most powerful way of working with SharePoint. Add a reference to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll. The object model has its pain points to be aware of however and can have a bit of a steep learning curve in some areas. Take note of the need to dispose of partially unmanaged objects such as SPSite and SPWeb if you take this route.
Alternatively use the SharePoint web services. These are quite simple and work well once you get their syntax correct. If your code cannot be deployed to the SharePoint server then they are your only option. The downside is that they are significantly reduced in functionality compared to the object model. You will certainly run up against this sooner or later which is why I recommend starting with the object model if possible.
The usual way is to refer to the MSDN documentation at http://msdn.microsoft.com/en-us/library/bb931736.aspx.
In Delphi, you then go to Component menu, Import component and then choose type library. Microsoft Sharepoint should be listed, but if it is not you can browse to find the client library. For Office 2007, that folder is C:\Program Files\Microsoft Office\Office12\OWSSUPP.DLL.
This will create a unit that contains definitions for all the Sharepoint interfaces and CoClasses. You would typically start of with one of the CoClasses, like CoMyStuff.Create to create an object that implements the MyStuff interface. Then follow the MSDN documentation to do what you want.

How can I add a ribbon menu to an existing MFC application?

Microsoft Visual C++ 2008 Feature Pack has ribbon menu support. Is it possible to make use of that in an existing MFC application that was not created with a ribbon menu?
It certainly is possible to take an existing MFC application and update it to use the ribbon in the MFC Feature Pack, and I've done this myself.
There are a couple of walkthrough articles on MSDN here that show how to do it, using the Scribble MFC sample application that you may be familiar with.
In essence, what you need to do is change your code to use the Feature Pack base classes instead of the standard MFC base classes - for example, replace CWinApp with CWinAppEx, CFrameWnd with CFrameWndEx, etc. Then you can add CMFCRibbonBar and CMFCRibbonApplicationButton objects to your main window class to create the ribbon itself. To get started I'd suggest downloading the Scribble sample and following the walkthough articles.
I hope this helps!
In addition to the resources pointed out by ChrisN, I recommend creating a new MFC application that includes a ribbon and examining the generated code..
Yes, it is surely possible to use the ribbon classes provided with the MFC Feature Pack.
A basic introduction is available here: Quick Tour Of New MFC Functionality and a more detailed tutorial can be found here: MFC Feature Pack Tutorial.
However, be aware that there is a rather strict license attached to it. For the conditions see Licensing the 2007 Microsoft Office User Interface and this related discussion on SO.

Resources