473,236 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 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 1907

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alex Lyman | last post by:
Does anyone have any code handy (or know what a good direction for me to head in), to call functions, if you have an address of the function, its declspec (for my app, it's limited to _stdcall and...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: komal | last post by:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function...
2
by: Joe | last post by:
I have 3 functions: ClientInfoA is doing something ClientInfoB is doing something SelectFunction2Run is a function to determine which function needed to run based on the value of the variable...
4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
2
by: 1388-2/HB | last post by:
On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: Nogema | last post by:
Hi everybody I use VB 2005 One of our project consisting in saving data on a network disk (NOVELL Sever) This project use windows authentification for each attempt to write on the disk,...
6
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.