|
I was saying you were right to set CharSet.Ansi since the function is declared using char* (which is always a single byte character). If you use CharSet.Auto or CharSet.Unicode , the string encoding is converted (if CharSet.Auto is set and you're running on Windows NT-based platforms).
The thing about function export spelling is common. ANSI functions are actually declared ending in "A" while Unicode functions are commonly declared ending in "W" like so:
int MyFuncA(LPCSTR lpszParam);
int MyFuncW(LPCWSTR lpszParam);
#ifdef UNICODE
#define MyFunc MyFuncW
#else
#define MyFunc MyFuncA
#endif That's a pretty basic example, though. It's to make sure that the right string encoding is used for the right platform.
Also, '\0' != null. First of all, in C# anything between single quotes is a char (System.Char ). A char is a value type and cannot be null (in .NET 2.0 char? is the same as Nullable<char> and can act like it's null, but value types still can't be null).
'\0' is the null character. This is the common representation in many programming languages, from C to C++ to C# to Perl to Java, etc. This is equal to (char)0 . What I was doing was initializing the string contents to the null character, the equivalent of which in unmanaged code is similar to:
LPTSTR lpszVar = NULL;
lpszVar = (LPTSTR)malloc(512 * sizeof(TCHAR));
_tcsnset(lpszVar, TEXT('\0'), 512);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ahh, I understand now.
Heath Stewart wrote:
The thing about function export spelling is common. ANSI functions are actually declared ending in "A" while Unicode functions are commonly declared ending in "W" like so:
I didn't know that, very interesting. I wish the function I was using would have specified (QuickFindModulesA)... That would have made, things easier.
Oh well, everything is cool. thanks for the info.
/\ |_ E X E GG
|
|
|
|
|
I have another question about another function.
int QuickOpen(HANDLE *hDevice, char *devName)
Right now i'm attacking this on like this...
[DllImport("quickfind.dll", CharSet = CharSet.Ansi)]
static extern int QuickOpen(IntPtr handle, [Out]string devName);
Do those conversions look right? Mainly, the HANDLE to IntPtr ...
Then I call it like this...
IntPtr ptr = new IntPtr();
string device = "QUSB-0\0\0";
int result = QuickOpen(ptr, device);
I get an AccessViolationException (.net 2.0 I think). If I switch IntPtr ptr for a StringBuilder ptr , the exception isn't thrown, but the data returned isn't an int it's a string... any idea?
/\ |_ E X E GG
|
|
|
|
|
IntPtr is a value type, and HANDLE is declared in unmanaged code as void* . So, you actually want to declare QuickOpen as:
[DllImport("quickfind.dll", CharSet=CharSet.Ansi)]
static extern int QuickOpen(out IntrPtr handle, string devName); The thing I'm not sure is whether the second param is an [out] parameter. Since the address of a handle (a pointer to a pointer) is passed, I presume its an [out] parameter. The purpose of this function, is it to open a device handle given a name (that's what I'm guessing by the way you're calling it). In that case, my declaration should be correct and you don't need to initialize IntPtr ptr , since it's passed as out ptr like so:
IntPtr ptr;
string device = "QUSB-0\0\0";
int result = QuickOpen(out ptr, device); Finally, why do you keep calling functions named xxxUsbyyy when you declare them as xxxyyy ? If you want to name the P/Invoke methods something different, declare the functions as whatever you want and set EntryPoint to the actual string name (still affected by ExactSpelling , if appropriate) of the exported native function.
Again, never expose P/Invoke methods publicly. You encapsulate them. This is good for another reason: to make otherwise difficult and procedural native APIs easy to use in an object-oriented way.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I am working with a C# web application in which a com object was used. This code was developed by someone else, it was trying to run this project on my laptop. I tried to register the com dll with regsvr32 command, but I was getting an error that says Interop.WINTERTREESPELLINGSERVERLib.dll was loaded, but DllRegisterServer entry point was not found.
DllRegisterServer may not be exported, or corrupt version of dll may be in memory. Consider using PView to detect and remove it.
Can someone suggest me how to solve this problem.
Thanks,
CodeLearner.
|
|
|
|
|
Interop.WINTERTREESPELLINGSERVERLib.dll doesn't have a DllRegisterServer function because it's just the RCW (runtime callable wrapper) assembly .NET uses to actually call the corresponding COM objects.
You have to register the original dll containing the COM objects you want to use with regsvr32.
Regards,
mav
|
|
|
|
|
To extend on what mav said, you should never register the interop assembly (the RCW) anyway. When you develop an RCW, it marshals calls to the original COM server. If you registered the RCW (a la regasm.exe, which is for registering CCWs) it would be the COM server but would contain no implementation. Your COM server is unavailable!
Only register the COM server (.dll, .exe, .ocx, whatever) using regsvr32.exe. If you develop a CCW (COM-Callable Wrapper), register that with regasm.exe that comes with the .NET Framework (i.e., not the SDK but the redistributable Framework).
There's several articles - including one of mine - that discuss this in greater detail.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for your replies Mav and Heath. I will try what you have suggested.
Thanks,
CodeLearner.
|
|
|
|
|
i hae this task which is to display each client load on the network , the display should be as a diagrame
|
|
|
|
|
Ok, your next step would be to design a solution for your stated goal.
Charlie
if(!curlies){ return; }
|
|
|
|
|
You'll have to have some kind of client application on each of your workstations to collect this kind of information and send it up to a central server. You can't possibly poll each and every computer for its network load constantly. The only other source of information MIGHT be the switch that the clients are connection to.
Also, when/if you write your client app, you'll have to define what consititutes "network load". Packets Sent/Received per second? Bytes Sent/Received per second? per minute? You can't send these statistics to a central server for collection constantly because you'll end up heavily skewing your data. Thus, you'll also have to specify at what interval the clients would have to report in with the server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
First you have to be sure what client load means, where the main issues are:
- how do you measure data? bytes, packets, etc.
- how do you measure time? sec, msec, hour..
If the answer to the second question is a long time, e.g. measuring the daily load, you might write a relatively simple client for each computer, and send the data to a "server" once a day. For the clients, you might want to use the Performance Counters, which u could access through the Server Explorer pane.
If you need much shorter measurement times, such as net load per second, sending data from clients screws up all measurements (and with some effort you could overload you're net). In such a case, you need some networking knowledge. If all the machines, e.g., are connected through a single switch, u could use one of the machines to sniff packets (in non/promicious mode? i don't remember). this is not so simple - try looking up winpcap which is a packet pick up library. i think that someone here has built a c# wrapper for it.
there are no facts, only interpretations
|
|
|
|
|
I am working on a SysTray App that has a context menu. The MenuItems listed in the menu will have subitems in each but I want the root item to be clickable so the .click event will trigger. Any ideas?
Thanks,
Cyber
|
|
|
|
|
The solution is not easy, and should not be used anyway. There are User Interface Guidelines for a reason and most applications follow them.
In this case, you should add a root menu item separated from it's children by a separator for each child menu. While this isn't common, it does not violate user interface guidelines.
An example would look like so:
Root
+-Parent1
| +-Parent1
| +--------
| +-Child1
| +-Child2
+-Parent2
| +-Parent2
| +--------
| +-Child1 This is also important because users can turn off the expansion of sub-menus by hovering over them, thus requiring them to click the menu to display its sub-menu.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I don't understand if I was to use the Context Menu Control how would I design what your describing?
Thanks,
Cyber
|
|
|
|
|
Quite easily. Add your menus and child menus as you normally do. Then add a menu where the text is the same as the parent text and drag that to the top of your child menu. Add a separator (Text should be set to "-" (without quotes)) and drag that just below the menu item described above. All you're doing is adding a menu item with the same text as the parent menu. You add your Click event handler to it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello,
How can i execute a MobileWebApplication on my Pocket Pc's that the application can consumes a WebService on my Desktop? - Do i need a Web-Server or something else on my PocketPc?? - Because only calling the MobileWebForm.aspx in my PocketExplorer does not work.
thx
regards
mat
|
|
|
|
|
hi,
You can check your IIS configuration first. Then visit these links.And we have lot of articles here in code project which will explain you step by step information of webservice conception.
Sometimes this may help you out.
http://www.devbuzz.com/content/zinc_compact_framework_web_service_xml_pg1.asp
http://www.pocketpcmag.com/_archives/may03/e_developers_corner.asp
http://www.ondotnet.com/pub/a/dotnet/2002/07/08/compactce.html?page=3
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I know the whole web service concept i only need to know how to set up and run a Mobile Web Appication on my PocketPc to consume a Web Service on a Server??? - because on the PocketPc does not exist an Web-Server and only call the MobileWebForm.aspx of the MobileWebApplication in the PocketExplorer does not work...??
regards
patrick
|
|
|
|
|
hi,
You Wrote :
I know the whole web service concept-
You may know the whole thing. If so you would have easy fix the problem . Am i right.
Your way of prsentation is not all good for this sort of free sites. Don't feel bad this is my openion.
And about answer. I am not the founder of WebService.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I don't know why you are upset about my posting. Sorry, but i only asked a question.
|
|
|
|
|
I know the whole web service concept i only need to know how to set up and run a Mobile Web Appication on my PocketPc to consume a Web Service on a Server??? - because on the PocketPc does not exist an Web-Server and only call the MobileWebForm.aspx of the MobileWebApplication in the PocketExplorer does not work...??
regards
mat
|
|
|
|
|
Hi,
I'm developing an application for mobile device in
Smart Device framework and i would like to know if there are extra controls for this framework in whidbey.
Thanks,
Shay.
|
|
|
|
|
hi,
I am not sure about extra controls but i can assure that our all avilable controls are seriously updated with new customiztion.
eg. Insted of datagrid here we have DataGridView.
See i wrote an article on Datagrid customiztion there i mentioned one url. Which connect you to the world of Whidbey. Try that
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi
Is there any mechanism to use locking facility in ADO.net for a table ? Pls suggest any solution for locking a record/table.
Warm Regards
Pradeep
|
|
|
|