serge's profileSerge Luca (Sharepoint M...PhotosBlogLists Tools Help

Blog


    August 31

    Calling Sharepoint Dlls from C++ code

     

    I spent most of the nineties  in the C++ world with the venerable MFC (Microsoft Foundation Classes) , ATL(Active Template Library) & its famous smart pointers.

    I recently had to answer a question in the Sharepoint newsgroups related to using Sharepoint dlls in C++:  I jumped on it as a kid in a candy store (to be honest my current candy store is Sharepoint 2010).

    This is what I did:

    Create a new CLR Console Application project :

     

    image

    The following code is generated :

     

    image

    Add a reference to the Microsoft.Sharepoint.dll :

     

    image

     

    image

    Define the Microsoft.Sharepoint namespace:

     

    image

    Write your C++; since Sharepoint classes are managed classes, you have to use the new gcnew operator and you don’t have to call delete.

    image

    Run the application :

     

    image

    Don’t forget, Visual C++ is the only compiler that allows you to mix-up managed and native code (we call that IJW or “It just works”); and this without the overhead of the PInvoke layer.

    This is quite simple, but it’s not your grandma’s C++ compiler anymore.


    Comments (7)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Oct. 31
    No namewrote:

    <p><a href="http://www.edhardy51.com/ed-hardy-shoes-c-32.html">ED Hardy shoes</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-women-boots-c-25.html">ED Hardy Women Boot</a></p>
    <p><a href="http://www.edhardy51.com/ed-hardy-jeans-c-33.html"> ED Hardy Jeans</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-watch-c-45.html">ED Hardy Watch</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-belts-c-47.html">ED Hardy Belts</a></p>
    <p><a href="http://www.edhardy51.com/ed-hardy-women-handbags-c-28.html"> ED Hardy Handbags</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-hoody-c-34.html">ED Hardy Hoody </a></p>
    <p><a href="http://www.edhardy51.com/ed-hardy-sweater-c-66.html">ED Hardy Sweater</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-tshirt-c-31.html">ED Hardy T-Shirt</a></p>
    <p><a href="http://www.edhardy51.com/ed-hardy-wallet-c-26.html"> ED Hardy Wallet</a></p>
    <p><a href="http://www.edhardy51.com/ed-hardy-sunglasses-c-30.html"> ED Hardy Sunglasses</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-hats-c-48.html">ED Hardy Hats</a></p>
    <p> <a href="http://www.edhardy51.com/ed-hardy-wool-cap-c-51.html">ED Hardy Wool Cap</a></p>
    Oct. 31
    风 林wrote:
    I think I will try to recommend this post to my friends and family, cuz it’s really helpful.[url="http://www.topugg.com/">Ugg Boots[/url] I think I will try to recommend this post to my friends and family, cuz it’s really helpful.<br />[url=http://www.topugg.com]UGG Boots[/url]
    Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far[url="http://www.topugg.com">UGG boots uk[/url] Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far<br />[url=http://www.topugg.com]UGG boots uk[/url]
    Thanks for article. Everytime like to read you.<br /><p><a href="http://www.topugg.com">cheap ugg boots</a></p> Thanks for article. Everytime like to read you.<br />[url=http://www.topugg.com]cheap ugg boots[/url]
    Only One word to characterize such a great post “WOW” that was a very interesting read<br /><p><a href="http://www.topugg.com">ugg boots sale</a></p> Only One word to characterize such a great post “WOW” that was a very interesting read<br />[url=http://www.topugg.com]ugg boots sale[/url]
    Everything dynamic and very positively!<br /><p><a href="http://www.topugg.com">ugg boot</a></p> Everything dynamic and very positively!<br />[url=http://www.topugg.com]ugg boot[/url]
    Nice post!Hey,have you heard about [url=http://www.bootsmall.co.uk] timberland boots[/url]
    I like it very much,such as [url=http://www.bootsmall.co.uk/classic-timberland-c-48.html] timberland work boots,it's cool and [url=http://www.bootsmall.co.uk/mens-rolltop-boots-c-41.html] roll top boots[/url] also very good. [url=http://www.bootsmall.co.uk/classic-timberland-c-48.html] Classic Timberland[/url]]
    [url=http://www.bootsmall.co.uk/kids-timberland-boots-c-43.html] Kids Timberland Boots[/url]]
    [url=http://www.bootsmall.co.uk/mens-6-inch-boots-c-40.html] Men's 6 Inch Boots[/url]]
    [url=http://www.bootsmall.co.uk/mens-chukka-boots-c-44.html] Men's Chukka Boots[/url]]
    [url=http://www.bootsmall.co.uk/mens-custom-boots-c-45.html] Men's Custom Boots[/url]]
    [url=http://www.bootsmall.co.uk/mens-rolltop-boots-c-41.html] Men's Roll-Top Boots[/url]]
    [url=http://www.bootsmall.co.uk/womens-6-inch-boots-c-42.html] Women's 6 Inch Boots[/url]]
    [url=http://www.bootsmall.co.uk/womens-high-top-boots-c-46.html] Women's High Top Boots[/url]]
    [url=http://www.bootsmall.co.uk/womens-rolltop-boots-c-47.html] Women's Roll-Top Boots[/url]
    Oct. 13
    serge Lucawrote:
    HI Joseph,

    to put you on the track, Sharepoint 2003 has a SPGlobalAdmin class which has a VirtualServer Collection
    A SPVirtualServer class (obsolete in 2007) which is the WebApplication .
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spglobaladmin.aspx
    SPVirtualServer has a Sites Property
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spvirtualserver.sites.aspx
    Site is a Collection of SiteCollections
    you can loop through each web application, each site collection and each site.
    Sept. 9
    nesanwrote:
    Hi.. Very nice to see this article here! I have learnt (a lttle) how to use SharePoint DLLs in c++ projects with your help. You have been exploring SharePoint 2010, but I like get some help from you in SharePoint Portal 2003. I believe that you could do it. :-)

    I think I should elaborate my requirement here before asking the help!
    My objective is to list all the portal sites present in a SharePoint Server (despite the version). I was successfully able to list them using "stsadm -o enumzoneurls" in MOSS2007. The XML output it gave was extremely useful to me. But this command fails in SPS 2003 as it requires "-url" parameter as mandatory. Only so I wished to try with SharePoint DLLs by using the namespaces and classes. Is there a way to list the portal sites in SPS 2003 using DLLs in C++? Assuming that I do not know a single URL. Can you mention the classes, methods and the usage technique. I believe this would help a lot of people with similar requirements.

    Hoping to get a response.

    Thanks & Regards,
    Nesan Joseph R.
    Sept. 7
    No namewrote:
    Very nice information. Thanks for this. Please come visit my site <a href="http://www.louisvillekyguide.com">Louisville Yellow Page Business Directory</a> when you got time.
    Sept. 3
    No namewrote:
    Can you provide more information on this? I am new to the subject. Please come visit my site <a href="http://www.coloradoaurora.com">Phone Directory Of Aurora City Colorado CO State </a> when you got time.
    Sept. 3

    Trackbacks

    The trackback URL for this entry is:
    http://sergeluca.spaces.live.com/blog/cns!E8A06D5F2F585013!6144.trak
    Weblogs that reference this entry
    • None