我基本上想要从c#中的用户获取int name和string age并将其发送到用c编写的dll方法,其中包含int和char [50]参数并返回字符串.i创建以下场景但我失败了,任何正文都有代码
我有一个在c开发的dll,它有一个结构
struct Argument
{
int age;
char name[50];
} ;
Run Code Online (Sandbox Code Playgroud)
和方法
extern "C"
{
__declspec(dllexport) Argument FillData(Argument data)
{
Argument mydata;
mydata.age=data.age;
for(int i=0;i<=sizeof(data);i++)
{
mydata.name[i]=data.name[i];
}
return mydata;
}
Run Code Online (Sandbox Code Playgroud)
我在Cs_dll.cs中的c#中声明它
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]
public struct Argument
{
public int age;
[MarshalAs(UnmanagedType.TBStr)]
//public char name;
public char[] name;
};
public class Cs_Dll
{
[DllImport("TestLib.dll")]
public static extern Argument FillData (Argument data);
}
Run Code Online (Sandbox Code Playgroud)
现在再按一个按钮我想做
private void button1_Click(object sender, EventArgs e)
{
Argument data=new Argument();
data.age=Convert.ToInt32(textBox_age.Text);
char[] name={'a','b','r','a','r', ' ', …Run Code Online (Sandbox Code Playgroud) 我正在尝试从iPhone网络应用程序使用Facebook Connect ,因此它看起来与使用Facebook Connect iPhone SDK的原生iPhone应用程序的外观类似.
iPhone SDK访问以下内容获得了很好的登录页面:
http://www.facebook.com/login.php?fbconnect=1&connect_display=touch&api_key=<key>&next=fbconnect://success
Run Code Online (Sandbox Code Playgroud)
(见http://github.com/facebook/facebook-iphone-sdk/blob/master/src/FBLoginDialog.m)
由于我不想打开Safari,我看到显示此页面的唯一方法是使用iframe.
然后是检测成功和失败的问题.
SDK可以通过简单地使用webView:shouldStartLoadWithRequest:委托方法并检查fbconnect://success和来完成此操作fbconnect://cancel.
据我所知,父页面无法监控iframe的URL.
我可以从父页面打开与服务器的Comet连接,并将Facebook重定向到我的服务器,然后成功通知父页面.但是我不喜欢因为这个而将服务器组件引入我的webapp的想法.
有没有人有任何聪明的想法?
编辑:这是关于网络应用程序,而不是本机应用程序.
我真的需要以一种可以通过机器翻译的方式来描述英语句子结构,并且是严格基于规则的(没有统计学的东西),它不一定是一个无上下文的语法,但这将是更好的(因为它不能完全描述它).我发现的最好的是BNF,但它非常基本.我需要一些没有例外的东西,除非有暧昧.有链接吗?
在我的PHP输出中,数字显示为1,234.56
如何将其更改为1234,56或1.234,56?
美国方式和欧洲方式是什么?
php是用美式方式工作的吗?
让我们首先说我的代码完全正常,没有问题.我只是想用一个很好的类来包装它以便将来动态使用,我想知道如何以最正确的方式在Javascript中做到这一点.
load_server是一个放置Ajax请求的函数.pagination()/ itemlinks()是遍历检索到的数据并标记链接以供将来使用Ajax的函数.我目前在函数中编写所有内容并将其转储到代码中,但我想创建类似于:
function ajaxRequest(type, link, container) {
this.after_success = null;
this.check_pagination = true;
if(typeof(type)) == ‘undefined’) this.type='';
if(typeof(link)) == ‘undefined’) this.link='';
if(typeof(container)) == ‘undefined’) this.container='';
this.pagination=function() {
//static function..
};
this.load_server=function () {
//function logic here..
};
while(mainReq.after_success) {
func();
}
}
var mainReq = new ajaxRequest{'link'};
mainReq.after_success = {
itemlinks = function() { },
morefunc = function() { }
};
mainReq.submit();
Run Code Online (Sandbox Code Playgroud)
我目前使用以下jQuery代码:
load_server = function (type, link, container) {
$(container).html("<div class='mask-loading'>Loading ...</div>");
$(container).load(getUrl,
function(responseText, textStatus, XMLHttpRequest) { //Callback …Run Code Online (Sandbox Code Playgroud) 在PHP中,使用一个包含很多函数的长类是否有任何性能影响?或者是否建议使用许多小班并在需要时单独调用它们?
我是OOPS的新手,请忽略问题中的任何愚蠢.谢谢.
例:
我想有两个不同的构造函数,我不想使用func_get_arg(),因为它是不可见的args是可能的.
写下两个是合法的,比如:
class MyClass {
public function __construct() {
// do something
}
public function __construct(array $arg) {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
?
我正在编写一个包含某个Web服务API的Python模块.这都是REST,所以实现相对简单.
但是,我发现单元测试时遇到了问题:由于我没有运行我为此模块制作的服务,我不想敲打它们,但与此同时,我需要检索数据来运行我的试验.我看了SimpleHTTPServer,没关系.
我解决了我遇到的部分问题,但是现在,因为我似乎无法终止该线程,所以在多次启动测试应用程序时,我遇到了"已经在使用地址"的问题.
这是一些示例代码
PORT = 8001
handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), handler)
httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.setDaemon(True)
httpd_thread.start()
api_data = urllib.urlopen("http://localhost:8001/post/index.json")
print "Data start:"
print json.load(api_data)
Run Code Online (Sandbox Code Playgroud)
其中"index.json"是我制作的模拟JSON文件,它取代了真实的东西.程序终止后如何优雅地清理东西?
当我尝试执行这样的命令时(从命令行或Perl脚本 - 这没关系):
svn revert "build\myfile@test.meta"
Run Code Online (Sandbox Code Playgroud)
SVN跳过此文件并输出:
Skipped 'build\myfile'
Run Code Online (Sandbox Code Playgroud)
我试过做:
svn revert "build\*.meta"
Run Code Online (Sandbox Code Playgroud)
但它给出了相同的结果.
我可以从GUI恢复这些文件.我可以通过执行来恢复这些文件(但它恢复的次数超出了我的要求):
svn revert --recursive "build"
Run Code Online (Sandbox Code Playgroud)
这有解决方法吗?