I want to pass a string array to C which uses ansi
in a test, I tried:
unsafe public int ctstAny1dp(Stri ng*[] strOut)
{
private string[] strMyC = {
"abcdef string 1",
"abcdef string 2",
"abcdef string 3",
"abcdef string 4",
"abcdef string 5"},
str2 = { "str2_1", "str2 2" };
// the above will be replaced by some other processing in production
// can't implicitly convert: strOut = strMyC;
for (int i = 0; i < strMyC.GetUpper Bound(0); i++)
{
strOut[i] =
((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ; };
return strMyC.GetUpper Bound(0) + 1;
}
the above won't compile: Error 1 Cannot implicitly convert type 'void*' to
'string*'. An explicit conversion exists (are you missing a cast?)
D:\data\Ieproj\ dotnet\IeString Class\C#\ieStri ngCS\ieStringCS \ieString.cs 99
26 ieStringCS
I thought I am getting a pointer to the string.
Is there a better way 5 1447
> strOut[i] = ((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ; };
This:
((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ;
returns a void* , you need to cast it to String*
Thx
but if I do this
strOut[i] = (String*)
((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ;
I get
Error 1 Cannot take the address of, get the size of, or declare a pointer to
a managed type ('string')
D:\data\Ieproj\ dotnet\IeString Class\C#\ieStri ngCS\ieStringCS \ieString.cs 100
26 ieStringCS
"PIEBALD" <PI*****@discus sions.microsoft .com> wrote in message
news:68******** *************** ***********@mic rosoft.com... strOut[i] = ((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ; };
This:
((Marshal.Strin gToHGlobalAnsi( strMyC[i])).ToPointer()) ;
returns a void* , you need to cast it to String*
Then you'll need someone better at it than I. Chances are you shouldn't be
producing an array of string pointers.
What is it you're trying to accomplish anyway?
I am just trying to find a way to pass via com interface to native
application caller a string array.
The desired native calling protocol is
// setup and connect muyoleobj to the c# com class..
// ...
string [] mystrArray[]
myoleobj.ctstAn y1dp(mystrArray )
"PIEBALD" <PI*****@discus sions.microsoft .com> wrote in message
news:16******** *************** ***********@mic rosoft.com... Then you'll need someone better at it than I. Chances are you shouldn't be producing an array of string pointers.
What is it you're trying to accomplish anyway?
Well I don't do COM, but I expect what you want is one method that handles
both the converting and the calling. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Henley |
last post by:
I first came across rebol a while ago; it seemed interesting but then
i was put off by its proprietary nature, although the core of the
language is a free download.
Recently however, i can't help but say i was totally impressed. I
needed an open source wikiblog/wikilog, whatever you wanna call it,
basically a hybrid of a blog and a wiki. I checked out snipsnap, which
uses java, it was said on their site to be a clone of vanilla, a...
|
by: E. Robert Tisdale |
last post by:
What makes a good C/C++ programmer?
Would you be surprised if I told you that
it has almost nothing to do with your knowledge of C or C++?
There isn't much difference in productivity, for example,
between a C/C++ programmers with a few weeks of experience
and a C/C++ programmer with years of experience.
You don't really need to understand the subtle details
or use the obscure features of either language
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
|
by: Madhur |
last post by:
Hello
what about this nice way to open a file in single line rather than using
if and else.
#include<stdio.h>
void main()
{
FILE *nd;
clrscr();
fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
|
by: Pyenos |
last post by:
import cPickle, shelve
could someone tell me what things are wrong with my code?
class progress:
PROGRESS_TABLE_ACTIONS=
DEFAULT_PROGRESS_DATA_FILE="progress_data"
PROGRESS_OUTCOMES=
| |
by: Siong.Ong |
last post by:
Dear all,
my PHP aims to update a MySQL database by selecting record
one by one and modify then save.
Here are my PHP, but I found that it doesnt work as it supposed to be,
for example, when Record (i) is shown and modified, the change will
come to Record (i+1).
Can anyone provide suggestion?
thanks.
|
by: Tubular Technician |
last post by:
Hello, World!
Reading this group for some time I came to the conclusion that
people here are split into several fractions regarding size_t,
including, but not limited to,
* size_t is the right thing to use for every var that holds the
number of or size in bytes of things.
* size_t should only be used when dealing with library functions.
|
by: Daniel.C |
last post by:
Hello.
I just copied this code from my book with no modification :
#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;
nc = 0;
|
by: MU |
last post by:
Hello
I have some code that sets a dropdownlist control with a parameter
from the querystring. However, when the querystring is empty, I get
an error.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
|
by: mingke |
last post by:
Hi...
So I have problem with my if condition..I don't know what's wrong but it keeps resulting the wrong answer....
So here's the part of my code I have problem with:
for (i=0; i<size2; i++){
for (k = 0; k < point3; k++){
|
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...
| |
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |