471,321 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

C# - calling Novell function (problem with variable types?)

Hello!

Can anyone help me with calling Novell function from dll?
I think my main problem is in translating C variable types to C# types.

Here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Globalization;

//declaring my class
public class IcNovell
{
[DllImport("calwin32.dll", CharSet = CharSet.Auto)]

public static extern int NWCallsInit(Byte reserved1, Byte
reserved2);

[DllImport("netwin32.dll", EntryPoint =
"NWDSCreateContextHandle", CharSet = CharSet.Auto, CallingConvention =
CallingConvention.Winapi, SetLastError = true)]

public static extern int GetHandle(out long context);

[DllImport("netwin32.dll", EntryPoint = "NWDSWhoAmI", CharSet =
CharSet.Auto, CallingConvention = CallingConvention.ThisCall,
SetLastError = true)]

public static extern int GetUser(long context, out string[]
NovellUserId);

}

//calling functions
// init
int cCode = IcNovell.NWCallsInit(0, 0);

long NovellContext = 0;
int RetCode0 = 0;
// get the context handle
RetCode0 = IcNovell.GetHandle(out NovellContext);
MessageBox.Show("RetCode0 is: " + RetCode0.ToString());
MessageBox.Show("Context is: "+NovellContext.ToString());
// my NovellContext equals 1 (looks good)

//string variable for user name
string[] NovellUserId = new string[255];
for (int i = 0; i < 255; i++)
{
NovellUserId[i] = " ";
}

int RetCode = 0;
// get the user name
RetCode = IcNovell.GetUser(NovellContext, out NovellUserId);
string hexValue = RetCode.ToString("X");
MessageBox.Show("RetCode is:" + hexValue);

At this point my RetCode is "FFFFFED1", which means (from Novell
documentation) "Trying to pass a bad context parameter to a NDS
function. Call NWDSCreateContextHandle first and use its return value as
the context parameter."
I think that variable NovellContext has wrong type (i got: long
NovellContext, maybe it should be IntPtr?).

In Novell documentation function declarations look like this:
NWDSCreateContextHandle
(http://developer.novell.com/ndk/doc/...7.html#sdk2687)
Syntax
C

#include <nwnet.h>
or
#include <nwdsdc.h>

N_EXTERN_LIBRARY (NWDSCCODE) NWDSCreateContextHandle (
NWDSContextHandle N_FAR *newHandle);

NWDSWhoAmI
(http://developer.novell.com/ndk/doc/...7.html#sdk2687)
Syntax
C

#include <nwnet.h>
or
#include <nwdsdsa.h>

N_EXTERN_LIBRARY (NWDSCCODE) NWDSWhoAmI (
NWDSContextHandle context,
pnstr8 objectName);
Any help will be appreciated.

Best regards,
Przemek
Dec 6 '05 #1
0 1763

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alex Lyman | last post: by
8 posts views Thread by Muthu | last post: by
2 posts views Thread by Joe | last post: by
2 posts views Thread by 1388-2/HB | last post: by
2 posts views Thread by Nogema | last post: by
6 posts views Thread by Ole Nielsby | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.