小编EXT*_*RAM的帖子

错误C1189:#error:此文件要求_WIN32_WINNT #defined至少为0x0500.建议值为0x0501或更高

我在VS2010(windows xp)中创建了MFC项目.我接受了这个错误:

error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended. 
Run Code Online (Sandbox Code Playgroud)

如果我加入afxcomctl32.h:#define _WIN32_WINNT 0x0501,我会犯60多个错误.在项目中,我没有添加任何东西.使用诸如Visual Studio创建的.我需要做什么?

c++ windows mfc visual-studio-2010

8
推荐指数
1
解决办法
3万
查看次数

如何在另一个线程Qt中显示MessageBox

这是我的代码:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    testApp w;
    w.show();
    TestClass *test = new TestClass;
    QObject::connect(w.ui.pushButton, SIGNAL(clicked()), test, SLOT(something()));
    return a.exec();
}
Run Code Online (Sandbox Code Playgroud)

TestClass.h

class TestClass: public QObject
{
    Q_OBJECT
    public slots:
        void something()
        {
            TestThread *thread = new TestThread;

            thread -> start();
        }

};
Run Code Online (Sandbox Code Playgroud)

TestThread.h

class TestThread: public QThread
{
    Q_OBJECT
protected:
    void run()
    {
        sleep(1000);
        QMessageBox Msgbox;
        Msgbox.setText("Hello!");
        Msgbox.exec();
    }

};
Run Code Online (Sandbox Code Playgroud)

如果我这样做,我会看到错误

必须在gui线程中创建小部件

我究竟做错了什么?请帮我.我知道我不能在另一个线程中改变gui,但我不知道qt中的构造.

c++ qt multithreading qmessagebox

8
推荐指数
1
解决办法
4161
查看次数

使用提供程序'RsaProtectedConfigurationProvider'无法解密

在我的应用程序中,连接到MS Sql数据库,我正在使用Microsoft.Data.ConnectionUI 和我的应用程序在我的计算机上工作.如果我在另一台计算机上运行此应用程序,当我打开连接对话框时,我看到该错误: 在此输入图像描述

这是我的代码:

    try
    {
        connectionString = ShowDialogConnection();

        SqlConnection connect = new SqlConnection(connectionString);
        connect.Open();
        backgroundWorker1.RunWorkerAsync();


    }
    catch (Exception exc)
    {
        MessageBox.Show(exc.ToString());
    }

string ShowDialogConnection()
        {
            string conn = "";
            DataConnectionDialog dlg = new DataConnectionDialog();
            DataSource.AddStandardDataSources(dlg);
            dlg.SelectedDataSource = DataSource.SqlDataSource;
            dlg.SelectedDataProvider = DataProvider.SqlDataProvider;
            if (ConfigurationManager.ConnectionStrings["ConStr"] != null)
            {
                dlg.ConnectionString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
            }
            if (DataConnectionDialog.Show(dlg) == DialogResult.OK)
            {
                if (dlg.ConnectionString != null && dlg.ConnectionString != "")
                {
                    conn = dlg.ConnectionString;
                    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    ConnectionStringsSection csSection = config.ConnectionStrings;
                    csSection.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
                    csSection.SectionInformation.ForceSave = …
Run Code Online (Sandbox Code Playgroud)

.net c# sql-server

6
推荐指数
1
解决办法
1万
查看次数

在内存中使用没有加载库的LinqToSql

我有一个问题.如果我正在使用LinqToSql,我的程序将我的数据库加载到内存中.小例子:

//pageNumber = 1; pageSize = 100;                
                var result =
                    (
                    from a in db.Stats.AsEnumerable()
                    where (DictionaryFilter(a, sourceDictionary) && DateFilter(a, beginTime, endTime) && ErrorFilter(a, WarnLevel))
                    select a
                    );
                var size = result.Count(); // size = 1007
                var resultList = result.Skip((pageNumber-1)*pageSize).Take(pageSize).ToList();
                return resultList;
Run Code Online (Sandbox Code Playgroud)

DictionaryFilter,DateFilter和ErrorFilter是过滤我的数据库的函数.在此之后我的程序使用~250Mb的Ram.如果我不使用:

var size = result.Count(); 
Run Code Online (Sandbox Code Playgroud)

我的程序使用~120MB Ram.在使用此代码之前,我的程序使用~35MB Ram.

如何使用count并将函数加载到内存中的所有数据库?

static bool DateFilter(Stat table, DateTime begin, DateTime end)
{

    if ((table.RecordTime >= begin.ToFileTime()) && (table.RecordTime <= end.ToFileTime()))
    {
        return true;
    }
    return false;
}
static bool ErrorFilter(Stat table, bool[] …
Run Code Online (Sandbox Code Playgroud)

.net c# linq linq-to-sql

3
推荐指数
1
解决办法
102
查看次数

NAudio WaveOut设备ID

我需要选择waveout设备,播放声音.但我不能这样做.

void Initialize()
{
_WaveOut = new WaveOut();
var reader = new WaveFileReader(FileName);
_WaveOut.Init(new WaveChannel32(reader));
}
Run Code Online (Sandbox Code Playgroud)

此函数启动,然后表单开始.在我的表单上,我选择带有组合框的waveout设备.Combobox是这段代码:

for (int i = 0; i < WaveOut.DeviceCount; i++)
{
     WaveOutCapabilities WOC = WaveOut.GetCapabilities(i);
     comboBox2.Items.Add(WOC.ProductName);

}
Run Code Online (Sandbox Code Playgroud)

在此之后,我选择了我的设备.

int WaveOutDeviceId = comboBox2.SelectedIndex;
Run Code Online (Sandbox Code Playgroud)

并启动Play功能:

void Play()
{
_WaveOut.DeviceNumber = WaveOutDeviceId;
_WaveOut.Play();
}
Run Code Online (Sandbox Code Playgroud)

但我的声音总是在默认设备上播放(数字= 0).如果我这样做麦克风,这段代码可以正常工作.

.net c# naudio

2
推荐指数
1
解决办法
4438
查看次数

NAudio C#中的麦克风缓冲区

我在麦克风上设置采样率(NAudio.WaveIn)44100Hz.但是当我使用WaveInDataAvailible(对象发送者,WaveInEventArgs e)时.在e.Buffer中我有4410,而不是44100个元素.为什么这需要我减少10倍的测量?

.net c# naudio

1
推荐指数
1
解决办法
1238
查看次数

使用WndClass的访问冲突读取位置

使用此代码,我遇到一个问题:

BOOL RegisterApp(HINSTANCE hInst)
{
    WNDCLASS wc;

    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInst;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
    wc.lpszClassName = szClassName;
    //

    //
    return RegisterClass(&wc);
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用时&wc,出现此错误:

Unhandled exception at 0x763adf81 in lab3.exe: 0xC0000005: Access violation reading location 0xcccccccc.
Run Code Online (Sandbox Code Playgroud)

请帮助我,我需要做什么?

c++ windows winapi

0
推荐指数
1
解决办法
364
查看次数