473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.Runtime. InteropServices ;
using System.Globaliz ation;

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

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

[DllImport("netw in32.dll", EntryPoint =
"NWDSCreateCont extHandle", CharSet = CharSet.Auto, CallingConventi on =
CallingConventi on.Winapi, SetLastError = true)]

public static extern int GetHandle(out long context);

[DllImport("netw in32.dll", EntryPoint = "NWDSWhoAmI ", CharSet =
CharSet.Auto, CallingConventi on = CallingConventi on.ThisCall,
SetLastError = true)]

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

}

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

long NovellContext = 0;
int RetCode0 = 0;
// get the context handle
RetCode0 = IcNovell.GetHan dle(out NovellContext);
MessageBox.Show ("RetCode0 is: " + RetCode0.ToStri ng());
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.GetUse r(NovellContext , out NovellUserId);
string hexValue = RetCode.ToStrin g("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 NWDSCreateConte xtHandle 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:
NWDSCreateConte xtHandle
(http://developer.novell.com/ndk/doc/...7.html#sdk2687)
Syntax
C

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

N_EXTERN_LIBRAR Y (NWDSCCODE) NWDSCreateConte xtHandle (
NWDSContextHand le N_FAR *newHandle);

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

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

N_EXTERN_LIBRAR Y (NWDSCCODE) NWDSWhoAmI (
NWDSContextHand le context,
pnstr8 objectName);
Any help will be appreciated.

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

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

Similar topics

5
2464
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 thiscall), and what parameters it expects? I know all about the argument ordering on the stack, but I don't really know enough ASM to work with it. Does anyone out there know of a cheap way to do it in more standardized C++? (efficiency doesn't...
8
2952
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 p3); The parameters here can be read either in the forward order from p1 till p3 or reverse order from p3 till p1. Can anyone explain what is the advantage/disadvantage of either of
6
1964
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 parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2()
2
1824
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 Method2Run. If the clientType is A, it would run ClientInfoA function. If it is clientType B, it would run the ClientInfoB function. Based on the value of Method2Run, how would I run the function dynamically? I know that there are many ways not to...
4
1728
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 question remaining: How to properly, simple and eleganty implement functions. The functions are encapsulated in the objects, the objects themselves are stored in a binary tree and objects contain 'methods' (functions) along with data. I don't want to...
2
2130
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 means my process identity varies, and is not necessarily "ASPNET" or "IUSR...". My process identity for any given page request will be user1, user2, user3, etc. (there's a lot of them) This web app needs to copy files (Word documents) from our old...
18
4341
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 can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
2
1481
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, the program leaves in error "ACCESS
6
11568
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 another convention unless they have an ellipsis argument.) I can force GCC and other compilers to use such a convention by declaring all methods with an ellipsis, but I'd rather not clutter my method definitions with these.
0
8268
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.