Notices


Reply
 
LinkBack Thread Tools Display Modes

Old 03-21-2007, 11:04 AM   #1 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 335
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

Using OleInitialize in .NET before using API

I am just starting my first foray into C# and thought what better way than to begin using it with the API!

I know that this applies to VB.NET too so I thought I would put the question out there. The knowledgebase article giving an example of how to use C# with the API says that if you want the login prompt then you should:

call the win32 OleInitialize api first.

as in the following:
Code:
REAPI oRE7 = new REAPI();

//initialize with amServermode to avoid
//splash screen and login prompt.  If you want to use amStandalone
//mode with the login prompt then you must call the win32 OleInitialize api first.
oRE7.Init ("WRE11111","Supervisor","admin",50,"",AppMode.amServer);

Does anyone have any examples of doing this? I cannot find the correct namespace for calling this. It is needed as the COM graphical objects use a different threading model to .NET and this will prevent a serious crash from occurring.

Thanks

David
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com


Last edited by DavidZ; 03-22-2007 at 05:12 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-22-2007, 05:38 PM   #2 (permalink)
o o o o o o o o o o o o o o o o o o

JeffMon's Avatar

Join Date: Aug 2006
Location: Charleston, SC
Posts: 54
Rep Power: 3 JeffMon is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- Financial Edge (FE)
- API/VBA

Hi David,
I haven't done it, but I believe that is an API call you have to register first, like so:

C#
Code:
[DllImport("ole32.dll")]
static extern int OleInitialize(IntPtr pvReserved);
VB.Net
Code:
Public Declare Function OLEInitialize Lib "ole32" Alias "OleInitialize" ()
As Integer
Also, when you call REAPI.Init, you'll need to leave the name/password blank, as well as the DB number if you want them to pick the DB to log into. Finally, you'll need to change the AppMode to Stand Alone... no point in a log-in form popping up on some remote server somewhere. ;-)

Jeff

PS - Good for you for picking up C#... I need to start doing the same.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-22-2007, 06:10 PM   #3 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 335
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

Thanks for that. I will have to try it and let you know what happens.

I have done it loads before in VB6 but just never in C#.

David
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-22-2007, 06:17 PM   #4 (permalink)
o o o o o o o o o o o o o o o o o o

JeffMon's Avatar

Join Date: Aug 2006
Location: Charleston, SC
Posts: 54
Rep Power: 3 JeffMon is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- Financial Edge (FE)
- API/VBA

'nother example:
Koders - Win32DnD.cs
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-23-2007, 05:01 AM   #5 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 335
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

I tried the example using VB.NET and it failed. I got an error message on the OLEInitialize function. I rewrote the code so that it matched the C#'s declaration and it worked fine.

Code:
Module Module1
   Public Declare Function OLEInitialize Lib "ole32" Alias "OleInitialize" (ByVal intp As IntPtr) As Integer
 
   Sub Main()
 
      OLEInitialize(Nothing)
 
      Dim oREAPI As New REDotNetAPI.REAPI
      Dim oConstit As REDotNetAPI.CRecord
 
      oREAPI.Init("WRE11111", , , 50, , REDotNetAPI.AppMode.amStandalone)
 
      oConstit = New REDotNetAPI.CRecord()
      oConstit.Init(oREAPI.SessionContext)
      oConstit.LoadByField(REDotNetAPI.bbRECORDUniqueFields.uf_Record_CONSTITUENT_ID, 3)
      System.Console.Write(oConstit.Fields(REDotNetAPI.ERECORDSFields.RECORDS_fld_FULL_NAME))
 
     oConstit.CloseDown()
     oConstit = Nothing
 
 
  End Sub
 
End Module
Note that this was written using a pre-7.80 version i.e. before RE included the interop assemblies so the namespace "REDotNetAPI" may be different on later versions.

David
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Old 03-23-2007, 06:34 PM   #6 (permalink)
Likes to customize RE!

DavidZ's Avatar

Join Date: Jul 2006
Location: London, UK
Posts: 335
Rep Power: 3 DavidZ is on a distinguished road

Blackbaud Products
- Raiser's Edge (RE)
- API/VBA

And here is the C# version.

Code:
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Text;
using Blackbaud.PIA.RE7.BBREAPI;
namespace MyProj
{
    class MyProj
    {

        [DllImport("ole32.dll")]
        static extern int OleInitialize(IntPtr pvReserved);
        [STAThread]
        static void Main(string[] args)
        {
            OleInitialize(IntPtr.Zero);
   
            REAPI oRE7 = new REAPI();
            //initialize with amServer mode to avoid
            //splash screen and login prompt.  If you want to use amStandalone
            //mode with the login prompt then you must call the win32 OleInitialize api first.
            oRE7.Init("WRE11111", string.Empty, string.Empty, 50, "", AppMode.amStandalone);
Hope this helps somebody else out there....

David
__________________
David Zeidman
Zeidman Development
http://www.zeidman.info

Check out my RE API blog
http://www.re-decoded.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
namespace, graphics, dotnet, csharp


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Cheap Gas - Loans - Loan - Credit Card Consolidation
All times are GMT -6. The time now is 11:21 AM.

Miscellaneous


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by BBpixel Team 2008 :: jvbPlugin R1012.364.1

SEO by vBSEO 3.2.0 Copyright 2008 Blackbaud User SocietyAd Management by RedTyger
Inactive Reminders By Icora Web Design

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64